// subtype is a common field. lets keep it here
$subtypes = CRM_Contact_BAO_Contact::buildOptions('contact_sub_type', 'create', array('contact_type' => $this->_contactType));
if (!empty($subtypes)) {
- $sel = $this->add('select', 'contact_sub_type', ts('Contact Type'),
- $subtypes, FALSE,
- array(
- 'id' => 'contact_sub_type',
- 'multiple' => 'multiple',
- 'class' => $buildCustomData . ' crm-select2',
- )
+ $this->addField('contact_sub_type', array(
+ 'label' => ts('Contact Type'),
+ 'options' => $subtypes,
+ 'class' => $buildCustomData,
+ 'multiple' => 'multiple',
+ 'options-url' => FALSE,
+ )
);
}
CRM_Contact_Form_Location::buildQuickForm($this);
// add attachment
- $this->addElement('file', 'image_URL', ts('Browse/Upload Image'), 'size=30 maxlength=60');
- $this->addUploadElement('image_URL');
+ $this->addField('image_URL', array('type' => 'File', 'size' => '30', 'maxlength' => '60', 'label' => ts('Browse/Upload Image')));
// add the dedupe button
$this->addElement('submit',
// Fetch options from the api unless passed explicitly.
if (isset($props['options'])) {
$options = $props['options'];
+ // Else this get passed to the form->add method.
+ unset($props['options']);
}
else {
$options = $fieldSpec['options'];
}
// Add data for popup link.
- if ($props['context'] != 'search' && $widget == 'Select' && CRM_Core_Permission::check('administer CiviCRM')) {
+ if ((isset($props['options-url']) && $props['options-url']) && ($props['context'] != 'search' && $widget == 'Select' && CRM_Core_Permission::check('administer CiviCRM'))) {
$props['data-option-edit-path'] = array_key_exists('option_url', $props) ? $props['option_url'] : $props['data-option-edit-path'] = CRM_Core_PseudoConstant::getOptionEditUrl($fieldSpec);
$props['data-api-entity'] = $props['entity'];
$props['data-api-field'] = $props['name'];
+ if (isset($props['options-url'])) {
+ unset($props['options-url']);
+ }
}
}
$props += CRM_Utils_Array::value('html', $fieldSpec, array());
if (empty($props['multiple'])) {
$options = array('' => $props['placeholder']) + $options;
}
- $this->add('select', $name, $label, $options, $required, $props);
+ $props += array('required' => $required);
+ $this->addElement('select', $name, $label, $options, $props);
// TODO: Add and/or option for fields that store multiple values
break;
//case 'AdvMulti-Select':
//case 'CheckBox':
- //case 'File':
+ case 'File':
+ // We should not build upload file in search mode.
+ if (isset($props['context']) && $props['context'] == 'search') {
+ return;
+ }
+ $this->addElement('file', $name, $label, $props, $required);
+ $this->addUploadElement($name);
+ break;
+
//case 'RichTextEditor':
//TODO: Add javascript template for wysiwyg.
case 'Autocomplete-Select':