value) && count($this->value) < 2) { $this->value = $this->value ? reset($this->value) : NULL; } $fields = $this->getFulltextFields(); $form['value'] = array( '#type' => 'select', '#title' => t('Searched fields'), '#description' => t('Select the fields that will be searched. If no fields are selected, all available fulltext fields will be searched.'), '#options' => $fields, '#size' => min(4, count($fields)), '#multiple' => TRUE, '#default_value' => $this->options['fields'], ); // Hide the value box if the operator is 'empty' or 'not empty'. // Radios share the same selector so we have to add some dummy selector. if (empty($form_state['exposed'])) { $form['value']['#states']['visible'] = array( ':input[name="options[operator]"],dummy-empty' => array('!value' => 'empty'), ':input[name="options[operator]"],dummy-not-empty' => array('!value' => 'not empty'), ); } elseif (!empty($this->options['expose']['use_operator'])) { $name = $this->options['expose']['operator_id']; $form['value']['#states']['visible'] = array( ':input[name="' . $name . '"],dummy-empty' => array('!value' => 'empty'), ':input[name="' . $name . '"],dummy-not-empty' => array('!value' => 'not empty'), ); } } /** * Extend the options form a bit. */ public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['operator']['#prefix'] = '
'; $form['operator']['#suffix'] = '
'; $form['value']['#prefix'] = '
'; $form['value']['#suffix'] = '
'; $form['titlesearch'] = array( '#type' => 'checkbox', '#title' => t('Expose the Searched fields filter'), '#description' => t('Allow the user to choose the fields to search.'), '#default_value' => !empty($this->options['titlesearch']['required']), ); $this->value_form($form, $form_state); $fields = $this->getFulltextFields(); if (!empty($fields)) { $form['fields'] = array( '#type' => 'select', '#title' => t('Searched fields'), '#description' => t('Select the fields that will be searched. If no fields are selected, all available fulltext fields will be searched.'), '#options' => $fields, '#size' => min(4, count($fields)), '#multiple' => TRUE, '#default_value' => $this->options['fields'], ); } else { $form['fields'] = array( '#type' => 'value', '#value' => array(), ); } if (isset($form['expose'])) { $form['expose']['#weight'] = -5; } } }