Skip to content
Advertisement

Why wont the Assertions validate my Symfony form?

I want to create a form with a bound DTO. I assert three attributes the DTO:

  • $firstName
  • $lastName
  • $image

One should only be asserted when I create a new object. The remaining two should always be asserted.

DTO

JavaScript

FormType

JavaScript

Controller

JavaScript

But even when I keep all fields blank, there are no messages about validation. The form allows me to save an empty form. I looked into the documentation but cant seem to find an answer. Why wont the assertions validate my form?

Advertisement

Answer

I am not sure, but adding “Default” to the validation groups should solve the problem.

JavaScript

By adding this option the Validator should take into consideration the assertions specified in the entity

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement