M
M
Messi2019-05-29 11:16:16
symfony
Messi, 2019-05-29 11:16:16

Checking for a minimum value in a form?

Please tell me there is a form:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('list',
            CollectionType::class,
            [
                'required' => false,
                'allow_add' => true,
                'error_bubbling' => true,
            ])
            ->add('price',
            IntegerType::class,
            [
                'required' => false,
                'error_bubbling' => true,
                'constraints' => [
                    new GreaterThanOrEqual(50)
                ],
            ]);
    }

How to specify here that the number price should be greater than or equal to 0? Tried like this:
'constraints' => [
                    new GreaterThanOrEqual(50)
                ],

But the validation doesn't work, skips any numbers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2019-05-29
@karminski

'constraints' => [
    new GreaterThanOrEqual(['value' => 0])
],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question