foreach ($privacyOptions as $name => $label) {
$privacy[] = $form->createElement('advcheckbox', $name, NULL, $label);
}
- $form->addGroup($privacy, 'privacy', ts('Privacy'), ' ');
+ $form->addGroup($privacy, 'privacy', ts('Privacy'), ' <br/>');
// preferred communication method
$comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method', array('loclize' => TRUE));
foreach ($comm as $value => $title) {
$commPreff[] = $form->createElement('advcheckbox', $value, NULL, $title);
}
- $form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Method(s)'));
-
- $form->addSelect('preferred_language');
+ $form->addField('preferred_communication_method', array('entity' => 'contact', 'type' => 'CheckBoxGroup'));
+ $form->addField('preferred_language', array('entity' => 'contact'));
if (!empty($privacyOptions)) {
$commPreference['privacy'] = $privacyOptions;
//using for display purpose.
$form->assign('commPreference', $commPreference);
- $form->add('select', 'preferred_mail_format', ts('Email Format'), CRM_Core_SelectValues::pmf());
- $form->add('checkbox', 'is_opt_out', ts('NO BULK EMAILS (User Opt Out)'));
+ $form->addField('preferred_mail_format', array('entity' => 'contact', 'label' => ts('Email Format')));
- $communicationStyleOptions = array();
- $communicationStyle = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'communication_style_id', array('localize' => TRUE));
- foreach ($communicationStyle as $key => $var) {
- $communicationStyleOptions[$key] = $form->createElement('radio', NULL,
- ts('Communication Style'), $var, $key,
- array('id' => "civicrm_communication_style_{$var}_{$key}")
- );
- }
- if (!empty($communicationStyleOptions)) {
- $form->addGroup($communicationStyleOptions, 'communication_style_id', ts('Communication Style'));
- }
+ $form->addField('is_opt_out', array('entity' => 'contact', 'label' => ts('NO BULK EMAILS (User Opt Out)')));
+ $form->addField('communication_style_id', array('entity' => 'contact', 'type' => 'RadioGroup'));
//check contact type and build filter clause accordingly for greeting types, CRM-4575
$greetings = self::getGreetingFields($form->_contactType);
return $group;
}
+ /**
+ * @param string $name
+ * @param $title
+ * @param $values
+ * @param array $attributes
+ * @param null $separator
+ * @param bool $required
+ *
+ * @return HTML_QuickForm_group
+ */
+ public function &addRadioGroup($name, $title, $values, $attributes = array(), $separator = NULL, $required = FALSE) {
+ return $this->addRadio($name, $title, $values, $attributes, $separator, $required);
+ }
+
/**
* @param int $id
* @param $title
}
}
+
+ /**
+ * @param int $id
+ * @param $title
+ * @param $values
+ * @param null $other
+ * @param null $attributes
+ * @param null $required
+ * @param null $javascriptMethod
+ * @param string $separator
+ * @param bool $flipValues
+ */
+ public function addCheckBoxGroup(
+ $id, $title, $values, $other = NULL, $attributes = NULL, $required = NULL,
+ $javascriptMethod = NULL, $separator = '<br />', $flipValues = FALSE
+ ) {
+ $this->addCheckBox(
+ $id, $title, $values, $other,
+ $attributes, $required, $javascriptMethod, $separator, $flipValues
+ );
+ }
+
public function resetValues() {
$data = $this->controller->container();
$data['values'][$this->_name] = array();
'Select Country',
'Multi-Select Country',
'AdvMulti-Select',
- 'CheckBox',
+ 'CheckBoxGroup',
+ 'RadioGroup',
'Radio',
)));
// TODO: Add and/or option for fields that store multiple values
break;
+ case 'CheckBoxGroup':
+ $this->addCheckBoxGroup($name, $label, array_flip($options), $required, $props);
+ break;
+
+ case 'RadioGroup':
+ $this->addRadioGroup($name, $label, $options, $props, NULL, $required);
+ break;
+
//case 'AdvMulti-Select':
case 'CheckBox':
$text = isset($props['text']) ? $props['text'] : NULL;
{/if}
</tr>
<tr>
- {foreach key=key item=item from=$commPreference}
- <td>
- <br /><span class="label">{$form.$key.label}</span> {help id="id-$key" file="CRM/Contact/Form/Contact.hlp"}
- {foreach key=k item=i from=$item}
- <br />{$form.$key.$k.html}
- {/foreach}
- </td>
- {/foreach}
- <td>
- <br /><span class="label">{$form.preferred_language.label}</span>
- <br />{$form.preferred_language.html}
- </td>
+ {foreach key=key item=item from=$commPreference}
+ <td>
+ <br/><span class="label">{$form.$key.label}</span> {help id="id-$key" file="CRM/Contact/Form/Contact.hlp"}
+ <br/>{$form.$key.html}
+ </td>
+ {/foreach}
+ <td>
+ <br/><span class="label">{$form.preferred_language.label}</span>
+ <br/>{$form.preferred_language.html}
+ </td>
</tr>
<tr>
<td>{$form.is_opt_out.html} {$form.is_opt_out.label} {help id="id-optOut" file="CRM/Contact/Form/Contact.hlp"}</td>
<export>true</export>
<comment>Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.</comment>
<add>4.4</add>
+ <html>
+ <type>Select</type>
+ </html>
</field>
<index>
<name>index_communication_style_id</name>