* @param int $entityID
* @param null $numAttachments
* @param bool $ajaxDelete
+ *
+ * @throws \CRM_Core_Exception
*/
public static function buildAttachment(&$form, $entityTable, $entityID = NULL, $numAttachments = NULL, $ajaxDelete = FALSE) {
$maxFileSize = $config->maxFileSize ? $config->maxFileSize : 2;
$currentAttachmentInfo = self::getEntityFile($entityTable, $entityID, TRUE);
- $totalAttachments = 0;
+ $totalAttachments = $currentAttachmentInfo ? count($currentAttachmentInfo) : 0;
if ($currentAttachmentInfo) {
- $totalAttachments = count($currentAttachmentInfo);
$form->add('checkbox', 'is_delete_attachment', ts('Delete All Attachment(s)'));
- $form->assign('currentAttachmentInfo', $currentAttachmentInfo);
- }
- else {
- $form->assign('currentAttachmentInfo', NULL);
}
+ $form->assign('currentAttachmentInfo', $currentAttachmentInfo);
if ($totalAttachments) {
if ($totalAttachments >= $numAttachments) {
'placeholder' => ts('Description'),
]);
+ $tagField = "tag_$i";
if (!empty($tags)) {
- $form->add('select', "tag_$i", ts('Tags'), $tags, FALSE,
+ $form->add('select', $tagField, ts('Tags'), $tags, FALSE,
[
'id' => "tags_$i",
'multiple' => 'multiple',
]
);
}
+ else {
+ $form->addOptionalQuickFormElement($tagField);
+ }
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, FALSE, TRUE, "file_taglist_$i");
}
}