public function CategoryForm::validateForm in Mass Contact 8
Form validation 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 FormBase::validateForm
File
- src/
Form/ CategoryForm.php, line 97
Class
- CategoryForm
- Class CategoryForm.
Namespace
Drupal\mass_contact\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$recipients_chosen = FALSE;
$mass_contact_category = $this->entity;
foreach ($this->groupingMethodManager
->getDefinitions() as $definition) {
if (!($plugin = $mass_contact_category
->getGroupingCategories($definition['id']))) {
$plugin = $this->groupingMethodManager
->createInstance($definition['id'], []);
}
if ($form['recipients'][$plugin
->getPluginId()]['categories']['#value']) {
$recipients_chosen = TRUE;
}
}
if (!$recipients_chosen) {
$form_state
->setErrorByName('', $this
->t('At least one recipient is required.'), 'error');
}
}