奥姆
My\SampleBundle\Entity\Subject:
type: entity
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
// ...
motion:
type: smallint
unsigned: true
类型
public function buildForm(FormBuilderInterface $builder,array $options)
{
// ...
$builder->add('motion','checkBox',array(
'required' => false
));
// ...
}
错误
Expected argument of type “Boolean”,“integer” given
我想通过复选框打开和关闭.
该值由0和1分配.
即使它给出了value参数也没用.
$builder->add('motion',array(
'value' => 1,'required' => false
));
我应该怎么做?
在ORM映射定义中,您必须将motion定义为布尔值而不是smallint.而且,仅供参考,Symfony将tinyint解释为布尔值,将任何其他整数sql类型解释为整数.
My\SampleBundle\Entity\Subject:
type: entity
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
// ...
motion:
type: boolean