public function TagSetForm::validateForm in Extensible BBCode 8.3
Same name and namespace in other branches
- 4.0.x src/Form/TagSetForm.php \Drupal\xbbcode\Form\TagSetForm::validateForm()
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/ TagSetForm.php, line 243
Class
- TagSetForm
- Base form for tag sets.
Namespace
Drupal\xbbcode\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) : void {
parent::validateForm($form, $form_state);
$exists = [];
$enabled = array_filter($form_state
->getValue('_tags'));
$settings =& $form_state
->getValue('_settings');
foreach (array_keys($enabled) as $key) {
$name = $settings[$key]['name'];
$exists[$name][$key] = $form['_settings'][$key]['name'];
}
foreach ($exists as $name => $rows) {
if (count($rows) > 1) {
foreach ((array) $rows as $row) {
$form_state
->setError($row, $this
->t('The name [@tag] is used by multiple tags.', [
'@tag' => $name,
]));
}
}
}
}