public function MegaMenuAdd::validateForm in The Better Mega Menu 2.x
Same name and namespace in other branches
- 8 src/Form/MegaMenuAdd.php \Drupal\tb_megamenu\Form\MegaMenuAdd::validateForm()
Overrides FormBase::validateForm
See also
\Drupal\Core\Form\FormBase::validateForm()
File
- src/
Form/ MegaMenuAdd.php, line 112
Class
- MegaMenuAdd
- Form handler for adding MegaMenuConfig entities.
Namespace
Drupal\tb_megamenu\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
if (MegaMenuConfig::loadMenu($form_state
->getValue('menu'), $form_state
->getValue('theme')) !== NULL) {
$form_state
->setErrorByName('menu', $this
->t("A Mega Menu has already been created for @menu / @theme", [
'@menu' => $form_state
->getValue('menu'),
'@theme' => $form_state
->getValue('theme'),
]));
}
}