Answer the question
In order to leave comments, you need to log in
Why is the form validator not working?
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('postcode', IntegerType::class, [
'required' => true,
'attr' => [
"min" => "1000",
"max" => "99999",
'minMessage' => 'min error message'
, 'maxMessage' => 'max error message'
],
'constraints' => array(
new Constraints\NotBlank(),
new Constraints\Type('integer'),
new Constraints\Regex(array(
'pattern' => '/^[0-9]\d*$/',
'message' => 'Please use only positive numbers.'
)
),
new Constraints\Length(array('min' => 4, 'max' => 5))
)
]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question