public function ConfigurationForm::submitForm in Views Natural Sort 8.2
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides ConfigFormBase::submitForm
File
- src/
Form/ ConfigurationForm.php, line 102
Class
- ConfigurationForm
- Defines a form that configures Views Natural Sort's settings.
Namespace
Drupal\views_natural_sort\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
// TODO: Change this to be handled by the transformation plugins.
$beginning_words_remove = explode(',', $values['beginning_words_remove']);
array_walk($beginning_words_remove, function (&$val) {
$val = trim($val);
});
$words_remove = explode(',', $values['words_remove']);
array_walk($words_remove, function (&$val) {
$val = trim($val);
});
$symbols_remove = trim($values['symbols_remove']);
$this
->config('views_natural_sort.settings')
->set('transformation_settings.remove_beginning_words.settings', $beginning_words_remove)
->set('transformation_settings.remove_words.settings', $words_remove)
->set('transformation_settings.remove_symbols.settings', $symbols_remove)
->set('transformation_settings.days_of_the_week.enabled', $values['days_of_the_week_enabled'])
->set('rebuild_items_per_batch', $values['rebuild_items_per_batch'])
->save();
$this
->messenger()
->addStatus($this
->t('The configuration options have been saved.'));
$this
->submitFormReindexOnly($form, $form_state);
}