3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Form helper class for an Email object.
21 class CRM_Contact_Form_Edit_Email
{
24 * Build the form object elements for an email object.
26 * @param CRM_Core_Form $form
27 * Reference to the form object.
28 * @param int $blockCount
29 * Block number to build.
30 * @param bool $blockEdit
33 public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = FALSE) {
34 // passing this via the session is AWFUL. we need to fix this
36 $blockId = ($form->get('Email_Block_Count')) ?
$form->get('Email_Block_Count') : 1;
39 $blockId = $blockCount;
42 $form->applyFilter('__ALL__', 'trim');
45 $form->addField("email[$blockId][email]", ['entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId])]);
46 $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email');
47 if (isset($form->_contactType
) ||
$blockEdit) {
49 $form->addField("email[$blockId][location_type_id]", ['entity' => 'email', 'placeholder' => NULL, 'class' => 'eight', 'option_url' => NULL]);
51 //TODO: Refactor on_hold field to select.
52 $multipleBulk = CRM_Core_BAO_Email
::isMultipleBulkMail();
57 0 => ts('- select -'),
58 1 => ts('On Hold Bounce'),
59 2 => ts('On Hold Opt Out'),
61 $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions);
64 $form->addField("email[$blockId][on_hold]", ['entity' => 'email', 'type' => 'advcheckbox', 'aria-label' => ts('On Hold for Email %1?', [1 => $blockId])]);
68 $form->assign('multipleBulk', $multipleBulk);
69 $js = ['id' => "Email_" . $blockId . "_IsBulkmail" , 'aria-label' => ts('Bulk Mailing for Email %1?', [1 => $blockId])];
71 $js['onClick'] = 'singleSelect( this.id );';
73 $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js);
76 $js = ['id' => "Email_" . $blockId . "_IsPrimary", 'aria-label' => ts('Email %1 is primary?', [1 => $blockId])];
78 $js['onClick'] = 'singleSelect( this.id );';
81 $form->addElement('radio', "email[$blockId][is_primary]", '', '', '1', $js);
83 if (CRM_Utils_System
::getClassName($form) == 'CRM_Contact_Form_Contact') {
85 $form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'),
86 ['rows' => 2, 'cols' => 40]
89 $form->add('wysiwyg', "email[$blockId][signature_html]", ts('Signature (HTML)'),
90 ['rows' => 2, 'cols' => 40]