I have entity with email field like this, field is not required, I just do not want to have nulls in DB columns:
class Entity {
/**
* @ORM\Column()
* @Assert\NotNull()
*/
protected $email = '';
}
How can I enforce default value if user bypass this field in a form?
Now validator throws an error that field cannot be null.
If all you care about is not having nulls in the DB then a couple options:
But your logic of having a non-required field unable to be blank does not make sense. You can either make it required or allow a null value.