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
预期参数类型为“Boolean”、“integer”
我想通过复选框打开和关闭。
该值按 0 和 1 分布。
即使给出了value参数也没有用。
$builder->add('motion', 'checkbox', 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)