Orm
My\SampleBundle\Entity\Subject:
type: entity
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
// ...
motion:
type: smallint
unsigned: true
Type
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...
$builder->add('motion', 'checkbox', array(
'required' => false
));
// ...
}
Error
Expected argument of type "Boolean", "integer" given
I would like to turn on and off by a check box.
The value is distributed by 0 and 1.
It was useless even if it gave the value parameter.
$builder->add('motion', 'checkbox', array(
'value' => 1,
'required' => false
));
How should I do?
In your ORM mapping definition, you have to define motion
as a boolean instead of a smallint. And FYI, Symfony interprets TINYINT as boolean and any other integer SQL types as integers.
My\SampleBundle\Entity\Subject:
type: entity
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
// ...
motion:
type: boolean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With