public function StateForm::validateForm in Booking and Availability Management Tools for Drupal 8
Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level validation handler, otherwise an exception will be thrown.
Overrides ContentEntityForm::validateForm
File
- modules/
bat_event/ src/ Entity/ Form/ StateForm.php, line 82 - Contains \Drupal\bat_event\Entity\Form\StateForm.
Class
- StateForm
- Class StateForm.
Namespace
Drupal\bat_event\Entity\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
if (!$form_state
->isValueEmpty('color') && !Color::validateHex($form_state
->getValue('color'))) {
$form_state
->setErrorByName('color', $this
->t('Color must be a hexadecimal color value.'));
}
}