private function MailchimpCampaignForm::buildMergeVarsHtml in Mailchimp 2.x
Same name and namespace in other branches
- 8 modules/mailchimp_campaign/src/Form/MailchimpCampaignForm.php \Drupal\mailchimp_campaign\Form\MailchimpCampaignForm::buildMergeVarsHtml()
Builds a HTML string used to render merge vars on the campaign form.
Parameters
array $merge_vars: Array of merge vars. @see mailchimp_lists_get_merge_vars.
Return value
string HTML string containing formatted merge vars.
1 call to MailchimpCampaignForm::buildMergeVarsHtml()
- MailchimpCampaignForm::getMergeVarsFormElements in modules/
mailchimp_campaign/ src/ Form/ MailchimpCampaignForm.php - Gets form elements used in the merge vars feature.
File
- modules/
mailchimp_campaign/ src/ Form/ MailchimpCampaignForm.php, line 828
Class
- MailchimpCampaignForm
- Form controller for the MailchimpCampaign entity edit form.
Namespace
Drupal\mailchimp_campaign\FormCode
private function buildMergeVarsHtml(array $merge_vars) {
if (!empty($merge_vars)) {
$element = [];
$element['mergevars_table'] = [
'#type' => 'table',
'#empty' => '',
];
foreach ($merge_vars as $var) {
$key = (string) $var->name;
$element['mergevars_table'][$key] = [
'#markup' => $var->name,
];
if (isset($var->link) && !is_null($var->link)) {
$element['mergevars_table'][$var->link] = [
'#markup' => '<a id="merge-var-' . $var->tag . '" class="add-merge-var" href="javascript:void(0);">*|' . $var->tag . '|*</a>',
];
}
}
return render($element);
}
else {
return $this
->t('No custom merge vars exist for the current audience.');
}
}