PHP / Symfony2表单复选框字段
发布时间:2020-12-13 14:10:16 所属栏目:PHP教程 来源:网络整理
导读:奥姆 MySampleBundleEntitySubject: type: entity id: id: type: integer generator: { strategy: AUTO } fields: // ... motion: type: smallint unsigned: true 类型 public function buildForm(FormBuilderInterface $builder,array $options){ // ...
奥姆
MySampleBundleEntitySubject: 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 )); // ... } 错误
我想通过复选框打开和关闭. $builder->add('motion',array( 'value' => 1,'required' => false )); 我应该怎么做?
在ORM映射定义中,您必须将motion定义为布尔值而不是smallint.而且,仅供参考,Symfony将TINYINT解释为布尔值,将任何其他整数SQL类型解释为整数.
MySampleBundleEntitySubject: type: entity id: id: type: integer generator: { strategy: AUTO } fields: // ... motion: type: boolean (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |