Well,I actually tested my form code in Chrome, Firefox and IE, but then when a friend tested my form in his Mac I discovered that the required field doesn't worked, because Safari doesn't accept the required class. So, at the end of the form when I press the send button I got the database error and it crashes.
I searched into the Symfony documentation and I found this piece of code on the form class:
public function setDefaultOptions(OptionsResolverInterface $resolver) {
$collectionConstraint = new Collection(array(
'name' => array(
new NotBlank(array('message' => 'Name should not be blank.')),
)
));
$resolver->setDefaults(array(
'constraints' => $collectionConstraint
));
}
But it seems to do nothing. Also I put on the Entity class this:
/**
* @Assert\NotBlank()
*/
public $name;
And still get the error. Any ideas what am I doing wrong? Thanks!