奥姆
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类型解释为整数.
原文链接:https://www.f2er.com/php/130907.htmlMy\SampleBundle\Entity\Subject: type: entity id: id: type: integer generator: { strategy: AUTO } fields: // ... motion: type: boolean