public function AddWordsForm::submitForm in Restrict Abusive Words 8
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 FormInterface::submitForm
File
- src/
Form/ AddWordsForm.php, line 72 - Contains \Drupal\restrict_abusive_words\Form\AdminSettingForm.
Class
- AddWordsForm
- Contribute form.
Namespace
Drupal\restrict_abusive_words\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$conn = Database::getConnection();
$words_list = explode("\n", $form_state
->getValue('words_list'));
$words = array_filter(array_map('trim', $words_list), 'strlen');
foreach ($words as $word) {
$conn
->insert('restrict_abusive_words')
->fields(array(
'words' => $word,
))
->execute();
drupal_set_message(t('Added word: %word', array(
'%word' => $row->words,
)));
}
$form_state
->setRedirect('restrict_abusive_words.list_words');
}