function SarniaViewsHandlerField::options_submit in Sarnia 7
Performs some cleanup tasks on the options array before saving it.
Overrides views_handler_field::options_submit
File
- handlers/
handler_field.inc, line 183
Class
- SarniaViewsHandlerField
- Field handler for displaying Solr fields in Views.
Code
function options_submit(&$form, &$form_state) {
parent::options_submit($form, $form_state);
// Set a reasonable label if it is the first save and none was specified, or
// if the the previous label matched the previous property name and has not
// been changed.
if (!isset($this->options['solr_property']) && $form_state['values']['options']['label'] == $this->definition['title'] || $this->options['solr_property'] == $this->options['label'] && $this->options['label'] == $form_state['values']['options']['label']) {
$form_state['values']['options']['label'] = $form_state['values']['options']['solr_property'];
}
// Check whether the field we're saving is multivalue, so that we don't have
// to check every single time we render the field.
$server = search_api_server_load($this->sarnia_type_info['search_api_server']);
$solr_fields = $server
->getRemoteFields();
$solr_property = $form_state['values']['options']['solr_property'];
$form_state['values']['options']['is_multivalue'] = !empty($solr_fields[$solr_property]) && $solr_fields[$solr_property]
->isMultivalued();
}