public function SearchApiFulltext::buildOptionsForm in Search API 8
Same name in this branch
- 8 src/Plugin/views/filter/SearchApiFulltext.php \Drupal\search_api\Plugin\views\filter\SearchApiFulltext::buildOptionsForm()
- 8 src/Plugin/views/argument/SearchApiFulltext.php \Drupal\search_api\Plugin\views\argument\SearchApiFulltext::buildOptionsForm()
Provide the basic form which calls through to subforms. If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.
Overrides FilterPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ filter/ SearchApiFulltext.php, line 154
Class
- SearchApiFulltext
- Defines a filter for adding a fulltext search to the view.
Namespace
Drupal\search_api\Plugin\views\filterCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['parse_mode'] = [
'#type' => 'select',
'#title' => $this
->t('Parse mode'),
'#description' => $this
->t('Choose how the search keys will be parsed.'),
'#options' => [],
'#default_value' => $this->options['parse_mode'],
];
foreach ($this
->getParseModeManager()
->getInstances() as $key => $mode) {
if ($mode
->isHidden()) {
continue;
}
$form['parse_mode']['#options'][$key] = $mode
->label();
if ($mode
->getDescription()) {
$states['visible'][':input[name="options[parse_mode]"]']['value'] = $key;
$form["parse_mode_{$key}_description"] = [
'#type' => 'item',
'#title' => $mode
->label(),
'#description' => $mode
->getDescription(),
'#states' => $states,
];
}
}
$fields = $this
->getFulltextFields();
if (!empty($fields)) {
$form['fields'] = [
'#type' => 'select',
'#title' => $this
->t('Searched fields'),
'#description' => $this
->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'] = [
'#type' => 'value',
'#value' => [],
];
}
if (isset($form['expose'])) {
$form['expose']['#weight'] = -5;
}
$form['min_length'] = [
'#title' => $this
->t('Minimum keyword length'),
'#description' => $this
->t('Minimum length of each word in the search keys. Leave empty to allow all words.'),
'#type' => 'number',
'#min' => 1,
'#default_value' => $this->options['min_length'],
];
}