You are here

public function SearchApiFulltext::buildExposeForm in Search API 8

Options form subform for exposed filter options.

Overrides FilterPluginBase::buildExposeForm

See also

buildOptionsForm()

File

src/Plugin/views/filter/SearchApiFulltext.php, line 214

Class

SearchApiFulltext
Defines a filter for adding a fulltext search to the view.

Namespace

Drupal\search_api\Plugin\views\filter

Code

public function buildExposeForm(&$form, FormStateInterface $form_state) {
  parent::buildExposeForm($form, $form_state);
  $form['expose']['placeholder'] = [
    '#type' => 'textfield',
    '#default_value' => $this->options['expose']['placeholder'],
    '#title' => $this
      ->t('Placeholder'),
    '#size' => 40,
    '#description' => $this
      ->t('Hint text that appears inside the field when empty.'),
  ];
  $form['expose']['expose_fields'] = [
    '#type' => 'checkbox',
    '#default_value' => $this->options['expose']['expose_fields'],
    '#title' => $this
      ->t('Expose searched fields'),
    '#description' => $this
      ->t('Expose the list of searched fields. This allows users to narrow the search to the desired fields.'),
  ];
  $form['expose']['searched_fields_id'] = [
    '#type' => 'textfield',
    '#default_value' => $this->options['expose']['searched_fields_id'],
    '#title' => $this
      ->t('Searched fields identifier'),
    '#size' => 40,
    '#description' => $this
      ->t('This will appear in the URL after the ? to identify this searched fields form element.'),
    '#states' => [
      'visible' => [
        ':input[name="options[expose][expose_fields]"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
}