Symfony boolean field in uniform

I have this field in essence:

/** * @ORM\Column(type="boolean") */ protected $done = 0; 

In the tinyint(1) database tinyint(1) . When I try to add it to the form:

 $builder ->add('done', 'checkbox') 

Gives an error message:

 Unable to transform value for property path "done": Expected a Boolean. 

BUT? Isn't that logical?

+7
php symfony
source share
1 answer

0 or 1 are not Boolean. They are integers. Use true / false in your domain model.

 /** * @ORM\Column(type="boolean") */ protected $done = false; 
+17
source share

All Articles