Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

check validator only if value present

How to validate only if value present in form element if there is class for form and validators are in form class


Add the parameter allowEmpty to the validator, ex:


$element->addValidator(new Regex([
    'allowEmpty' => TRUE,
    'pattern'    => '/^\d{2}:\d{2}$/'