Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tags fields are assigned to tpl for email form test #23183

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public function preProcess() {
* @return array
*/
public function getOptionalQuickFormElements(): array {
return ['separation', 'tag'];
return array_merge(['separation', 'tag'], $this->optionalQuickFormElements);
}

/**
Expand Down
16 changes: 9 additions & 7 deletions CRM/Core/BAO/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ public static function sql($entityTable, $entityID, $fileTypeID = NULL, $fileID
* @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) {

Expand All @@ -442,15 +444,11 @@ public static function buildAttachment(&$form, $entityTable, $entityID = NULL, $
$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) {
Expand Down Expand Up @@ -487,8 +485,9 @@ public static function buildAttachment(&$form, $entityTable, $entityID = NULL, $
'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',
Expand All @@ -497,6 +496,9 @@ public static function buildAttachment(&$form, $entityTable, $entityID = NULL, $
]
);
}
else {
$form->addOptionalQuickFormElement($tagField);
}
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, FALSE, TRUE, "file_taglist_$i");
}
}
Expand Down
1 change: 1 addition & 0 deletions CRM/Core/Form/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static function buildQuickForm(
}
}

$form->addExpectedSmartyVariable('tagsetInfo');
if (!empty($tagset)) {
// assign current tagsets which is used in postProcess
$form->_tagsetInfo = $tagset;
Expand Down
20 changes: 10 additions & 10 deletions templates/CRM/Form/attachment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div id="attachFileRecord_{$attVal.fileID}">
<strong><a href="{$attVal.url}"><i class="crm-i {$attVal.icon}" aria-hidden="true"></i> {$attVal.cleanName}</a></strong>
{if $attVal.description}&nbsp;-&nbsp;{$attVal.description}{/if}
{if !empty($attVal.tag)}
{if $attVal.tag}
<br />
{ts}Tags{/ts}: {$attVal.tag}
<br />
Expand All @@ -27,20 +27,20 @@
</td>
</tr>
{elseif $action NEQ 4}
{if !empty($context) && $context EQ 'pcpCampaign'}
{if $context EQ 'pcpCampaign'}
{capture assign=attachTitle}{ts}Include a Picture or an Image{/ts}{/capture}
{else}
{capture assign=attachTitle}{ts}Attachment(s){/ts}{/capture}
{/if}
<div class="crm-accordion-wrapper {if (empty($context) || $context NEQ 'pcpCampaign') AND empty($currentAttachmentInfo)}collapsed{/if}">
<div class="crm-accordion-wrapper {if (!$context || $context NEQ 'pcpCampaign') AND !$currentAttachmentInfo}collapsed{/if}">
<div class="crm-accordion-header">
{$attachTitle}
</div><!-- /.crm-accordion-header -->
<div class="crm-accordion-body">
<div id="attachments">
<table class="form-layout-compressed">
{if !empty($form.attachFile_1)}
{if !empty($context) && $context EQ 'pcpCampaign'}
{if $form.attachFile_1}
{if $context EQ 'pcpCampaign'}
<div class="description">{ts}You can upload a picture or image to include on your page. Your file should be in .jpg, .gif, or .png format. Recommended image size is 250 x 250 pixels. Images over 360 pixels wide will be automatically resized to fit.{/ts}</div>
{/if}
<tr>
Expand All @@ -49,13 +49,13 @@
<div class="description">{ts}Browse to the <strong>file</strong> you want to upload.{/ts}{if $maxAttachments GT 1} {ts 1=$maxAttachments}You can have a maximum of %1 attachment(s).{/ts}{/if} {ts 1=$config->maxFileSize}Each file must be less than %1M in size. You can also add a short description.{/ts}</div>
</td>
</tr>
{if !empty($form.tag_1.html)}
{if $form.tag_1}
<tr>
<td class="label">{$form.tag_1.label}</td>
<td><div class="crm-select-container crm-attachment-tags">{$form.tag_1.html}</div></td>
</tr>
{/if}
{if !empty($tagsetInfo.file)}
{if $tagsetInfo && $tagsetInfo.file}
<tr>{include file="CRM/common/Tagset.tpl" tagsetType='file' tableLayout=true tagsetElementName="file_taglist_1"}</tr>
{/if}
{section name=attachLoop start=2 loop=$numAttachments+1}
Expand All @@ -68,13 +68,13 @@
<td class="label">{$form.attachFile_1.label}</td>
<td>{$form.$attachName.html}&nbsp;{$form.$attachDesc.html}<a href="#" class="crm-hover-button crm-clear-attachment" style="visibility: hidden;" title="{ts}Clear{/ts}"><i class="crm-i fa-times" aria-hidden="true"></i></a></td>
</tr>
{if !empty($form.$tagElement.html)}
{if $form.$tagElement}
<tr>
<td class="label">{$form.$tagElement.label}</td>
<td><div class="crm-select-container crm-attachment-tags">{$form.$tagElement.html}</div></td>
</tr>
{/if}
{if !empty($tagsetInfo.file)}
{if $tagsetInfo && $tagsetInfo.file}
<tr>{include file="CRM/common/Tagset.tpl" tagsetType='file' tableLayout=true tagsetElementName="file_taglist_$index"}</tr>
{/if}
{/section}
Expand All @@ -92,7 +92,7 @@
{if $attVal.deleteURLArgs}
<a href="#" class="crm-hover-button delete-attachment" data-filename="{$attVal.cleanName}" data-args="{$attVal.deleteURLArgs}" title="{ts}Delete File{/ts}"><span class="icon delete-icon"></span></a>
{/if}
{if !empty($attVal.tag)}
{if $attVal.tag}
<br/>
{ts}Tags{/ts}: {$attVal.tag}
<br/>
Expand Down