public function AutocompletionConfigurationAddForm::save in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Form/AutocompletionConfigurationAddForm.php \Drupal\search_autocomplete\Form\AutocompletionConfigurationAddForm::save()
Overrides Drupal\Core\Entity\EntityFormController::save().
Saves the entity. This is called after submit() has built the entity from the form values. Do not override submit() as save() is the preferred method for entity form controllers.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: An associative array containing the current state of the form.
Overrides AutocompletionConfigurationFormBase::save
File
- src/
Form/ AutocompletionConfigurationAddForm.php, line 59
Class
- AutocompletionConfigurationAddForm
- Class AutocompletionConfigurationAddForm.
Namespace
Drupal\search_autocomplete\FormCode
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
// Add default values on the entity.
$this->entity
->setStatus(TRUE);
$this->entity
->setMinChar(3);
$this->entity
->setMaxSuggestions(10);
$this->entity
->setAutoSubmit(TRUE);
$this->entity
->setAutoRedirect(TRUE);
$this->entity
->setMoreResultsLabel($this
->t('View all results for [search-phrase].'));
$this->entity
->setMoreResultsValue($this
->t('[search-phrase]'));
$this->entity
->setMoreResultsLink('');
$this->entity
->setNoResultLabel($this
->t('No results found for [search-phrase]. Click to perform full search.'));
$this->entity
->setNoResultValue($this
->t('[search-phrase]'));
$this->entity
->setNoResultLink('');
$this->entity
->setSource('autocompletion_callbacks_nodes::nodes_autocompletion_callback');
$this->entity
->setTheme('basic-blue.css');
$this->entity
->setEditable(TRUE);
$this->entity
->setDeletable(TRUE);
$this->entity
->save();
// Redirect to edit form once entity is added.
$form_state
->setRedirectUrl($this->entity
->toUrl('edit-form'));
}