PHP/Symfony2表单复选框字段
奥姆 类型 错误 应为“Boolean”、“integer”类型的参数PHP/Symfony2表单复选框字段,php,symfony,checkbox,Php,Symfony,Checkbox,奥姆 类型 错误 应为“Boolean”、“integer”类型的参数 我想通过复选框打开和关闭。 该值由0和1分配。 即使它给出了value参数,它也是无用的 public function buildForm(FormBuilderInterface $builder, array $options) { // ... $builder->add('motion', 'checkbox', array( 'required' => false
我想通过复选框打开和关闭。 该值由0和1分配。
即使它给出了value参数,它也是无用的
public function buildForm(FormBuilderInterface $builder, array $options)
{
// ...
$builder->add('motion', 'checkbox', array(
'required' => false
));
// ...
}
该怎么做?在ORM映射定义中,必须将
运动定义为布尔值,而不是smallint。仅供参考,Symfony将TINYINT解释为boolean,将任何其他整数SQL类型解释为整数
$builder->add('motion', 'checkbox', array(
'value' => 1,
'required' => false
));
非常感谢。你真的让我很轻松。
$builder->add('motion', 'checkbox', array(
'value' => 1,
'required' => false
));
My\SampleBundle\Entity\Subject:
type: entity
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
// ...
motion:
type: boolean