+ // FIXME: Why are select state/country separate widget types?
+ if (in_array($field->html_type, array('Select', 'Multi-Select', 'Select State/Province', 'Multi-Select State/Province', 'Select Country', 'Multi-Select Country'))) {
+ $selectAttributes = array(
+ 'data-crm-custom' => $dataCrmCustomVal,
+ 'class' => 'crm-select2',
+ );
+ if (strpos($field->html_type, 'Multi') === 0) {
+ $selectAttributes['multiple'] = 'multiple';
+ }
+ }
+ // Add data so popup link. Normally this is handled by CRM_Core_Form->addSelect
+ if (in_array($field->html_type, array('Select', 'Multi-Select')) && !$search && CRM_Core_Permission::check('administer CiviCRM')) {
+ $selectAttributes += array(
+ 'data-api-entity' => 'contact', // FIXME: This works because the getoptions api isn't picky about custom fields, but it's WRONG
+ 'data-api-field' => 'custom_' . $field->id,
+ 'data-option-edit-path' => 'civicrm/admin/options/' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $field->option_group_id),
+ );
+ }
+