I have a form containing a field that expects an integer. This is the field definition in the form type entity definition:
/**
* @ORM\Column(type="integer", nullable=true)
* @Assert\Type(type="integer", message="Number of pieces must be a number.")
* @Assert\GreaterThanOrEqual(value=1, message="Number of pieces cannot be lower than 1.")
*/
protected $numberOfPiecesSent;
The relevant form builder looks like this:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('numberOfPiecesSent', 'integer', array('label' => 'Number of pieces sent:', 'required' => false));
}
When I submit the form with a non-numerical value in the field (say, 'aaa'), it just saves the form and leaves the field numberOfPiecesSent NULL in the database instead of failing on validation. I also tried to make the field non-NULL, but that didn't help. Any ideas why this isn't working, please?