public function SuggestionEditForm::submitForm in Autocomplete Search Suggestions 8
Same name and namespace in other branches
- 8.2 src/Form/SuggestionEditForm.php \Drupal\suggestion\Form\SuggestionEditForm::submitForm()
- 3.0.x src/Form/SuggestionEditForm.php \Drupal\suggestion\Form\SuggestionEditForm::submitForm()
AJAX callback for the indexing form.
Parameters
array $form: A drupal form array.
Drupal\Core\Form\FormStateInterface $form_state: A Drupal form state object.
Overrides FormInterface::submitForm
File
- src/
Form/ SuggestionEditForm.php, line 102
Class
- SuggestionEditForm
- Suggestion indexing form.
Namespace
Drupal\suggestion\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$src = 0;
foreach ((array) $form_state
->getValue('src') as $bit) {
$src |= intval($bit);
}
$key = [
'ngram' => $form_state
->getValue('ngram'),
];
$fields = [
'atoms' => $form_state
->getValue('atoms'),
'density' => SuggestionHelper::calculateDensity($src, $form_state
->getValue('atoms'), $form_state
->getValue('qty')),
'qty' => $form_state
->getValue('qty'),
'src' => $src,
];
SuggestionStorage::mergeSuggestion($key, $fields);
drupal_set_message($this
->t('Updated: “@ngram”', [
'@ngram' => $form_state
->getValue('ngram'),
]));
}