'title' => ts('Activity Type'),
'name' => 'activity_type',
'type' => CRM_Utils_Type::T_STRING,
+ 'searchByLabel' => true,
),
'activity_status' => array(
'title' => ts('Activity Status'),
'name' => 'activity_status',
'type' => CRM_Utils_Type::T_STRING,
+ 'searchByLabel' => true,
),
);
$fields = array_merge($Activityfields, $exportableFields);
// Get fields of type date
// FIXME: This is a hack until our fields contain this meta-data
$dateFields = array();
+ $searchByLabelFields = array();
foreach ($fields as $name => $field) {
if (strpos($name, '_date') || CRM_Utils_Array::value('data_type', $field) == 'Date') {
$dateFields[] = $name;
}
+ // it's necessary to know which of the fields are searchable by label
+ if (isset($field['searchByLabel']) && $field['searchByLabel']) {
+ $searchByLabelFields[] = $name;
+ }
}
// Add javascript
CRM_Core_Resources::singleton()
'newBlock' => $this->get('newBlock'),
'dateFields' => $dateFields,
'fieldOptions' => self::fieldOptions(),
+ 'searchByLabelFields' => $searchByLabelFields,
),
));
//get the saved search mapping id
}
}
$.each(CRM.searchBuilder.fieldOptions[field], function(key, option) {
- var selected = ($.inArray(''+option.key, options) > -1) ? 'selected="selected"' : '';
+ var optionKey = option.key;
+ if ($.inArray(field, CRM.searchBuilder.searchByLabelFields) >= 0) {
+ optionKey = option.value;
+ }
+ var selected = ($.inArray(''+optionKey, options) > -1) ? 'selected="selected"' : '';
select.append('<option value="' + option.key + '"' + selected + '>' + option.value + '</option>');
});
select.change();