Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forcing Symfony form validation without actual submission

Is it possible to perform form fields validation manually, forced?

I have a form. It has a global form validation. Everything works well if user submits data.

But I want to trigger validation before form is displayed to the user - show errors before submit.

Tried to submit using $form->submit([]) method but it doesn't trigger form fields validation.

Any ideas on this issue? Did I something wrong?

like image 847
eRIZ Avatar asked Oct 20 '22 01:10

eRIZ


1 Answers

Do you need to validate a data only by form? Doesn't a validator service work for you?

Like

$violations = $this->get('validator')->validate($entity);
like image 138
Dmitry Malyshenko Avatar answered Oct 22 '22 00:10

Dmitry Malyshenko