public function SavedSearchForm::form in Search API Saved Searches 8
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ SavedSearchForm.php, line 16
Class
- SavedSearchForm
- Provides a standard form for editing saved searches.
Namespace
Drupal\search_api_saved_searches\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\search_api_saved_searches\SavedSearchInterface $search */
$search = $this
->getEntity();
$args['%search_label'] = $search
->label();
$form['#title'] = $this
->t('Edit saved search %search_label', $args);
if ($search
->getType()
->getOption('allow_keys_change', FALSE) && !is_array($search
->getQuery()
->getOriginalKeys())) {
$keywords = $search
->getQuery()
->getOriginalKeys();
$form['search_keywords'] = [
'#type' => 'textfield',
'#title' => $this
->t('Fulltext keywords'),
'#description' => $this
->t('The fulltext keywords set on this search.'),
'#default_value' => $keywords,
];
}
return $form;
}