You are here

public function SarniaViewsHandlerArgumentId::options_form in Sarnia 7

Add a field to the options form to select a solr property to use as the name of the argument.

Overrides SarniaViewsHandlerArgument::options_form

File

handlers/handler_argument_id.inc, line 32
Views argument handler for Solr document Ids.

Class

SarniaViewsHandlerArgumentId
@file Views argument handler for Solr document Ids.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // Remove the 'solr_property' configuration from SarniaViewsHandlerArgument::options_form().
  unset($form['solr_property']);

  // Add the combobox for the title solr property above the 'title' field.
  $new_form = array();
  foreach (array_keys($form) as $key) {
    if ($key == 'title_enable') {
      $new_form['name_solr_property'] = array(
        '#type' => 'select',
        '#title' => t('Argument name solr property'),
        '#description' => t('Use a different solr property when overriding the argument title instead of the id.'),
        '#options' => sarnia_index_get_field_options($this->definition['search_api_index']),
        '#default_value' => $this->options['name_solr_property'],
        '#fieldset' => 'argument_present',
      );
      sarnia_element_add_combobox($new_form['name_solr_property']);
    }
    $new_form[$key] = $form[$key];
  }
  $form = $new_form;
}