public function SearchApiRangesAlter::configurationForm in Search API ranges 7
Implements SearchApiAlterCallbackInterface::configurationForm().
Overrides SearchApiAbstractAlterCallback::configurationForm
File
- includes/
callback_search_api_ranges.inc, line 12
Class
- SearchApiRangesAlter
- Search API ranges data alteration callback that indexes the min and max of selected numeric fields.
Code
public function configurationForm() {
// Retrieve indexed fields.
$fields = $this->index
->getFields(TRUE);
$field_options = array();
$this->options += array(
'fields' => array(),
);
$eligible_types = array(
'integer',
'decimal',
);
foreach ($fields as $name => $field) {
if (search_api_is_list_type($field['type']) && in_array(search_api_extract_inner_type($field['type']), $eligible_types)) {
$field_options[$name] = $field['name'];
}
}
if (!empty($field_options)) {
$form['fields'] = array(
'#type' => 'fieldset',
'#title' => t('Fields to run on'),
);
foreach ($field_options as $field_name => $label) {
$default_value = FALSE;
if (isset($this->options['fields'][$field_name])) {
if (!is_array($this->options['fields'][$field_name])) {
$default_value = TRUE;
}
else {
if (!empty($this->options['fields'][$field_name]['name'])) {
$default_value = TRUE;
}
}
}
$form['fields'][$field_name]['enabled'] = array(
'#type' => 'checkbox',
'#title' => $label,
'#default_value' => $default_value,
);
$form['fields'][$field_name]['name'] = array(
'#type' => 'value',
'#value' => $label,
);
$form['fields'][$field_name]['description'] = array(
'#type' => 'value',
'#value' => isset($fields[$field_name]['description']) ? $fields[$field_name]['description'] : '',
);
$form['fields'][$field_name]['type'] = array(
'#type' => 'value',
'#value' => search_api_extract_inner_type($fields[$field_name]['type']),
);
}
return $form;
}
}