M
M
magary42017-03-29 14:52:11
symfony
magary4, 2017-03-29 14:52:11

Form->isValid is always true?

In the form class, all fields are defined as required
for the test in the template did so

{{ form_start( form, { attr: { "novalidate": "novalidate" } } ) }}

I submit the form and in the controller $form->isValid() is true. why?
the form itself is not tied to doctrine entities
or how to do it right by calling $formData = $form->getData(); in the controller - ensure that
$formData["name"], $formData["phone"] etc are present and valid and accessing them will not result in an error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Vlastovskiy, 2017-05-23
@magary4

From documentation :
That is, the fact that your form contains fields with 'required' => true (it's the default) does not affect validation.
Therefore, $form->isValid() === true
if you do not have a Doctrine class or entity to which the form is displayed, you need to write the validation rules yourself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question