简体   繁体   English

Symfony2复选框和原理

[英]Symfony2 checkboxes & Doctrine

I would like to record a choice of checkboxes in my data base. 我想在数据库中记录复选框的选择。 I get this error: 我收到此错误:

ContextErrorException: Notice: Array to string conversion in //vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php line 120 ContextErrorException:注意://vendor/doctrine/dbal/lib/Doctrine/DBAL/Statement.php第120行中的数组到字符串的转换

My form : 我的表格:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('adult_available', 'choice', array(
            'choices'   => array('A' => 'Adult', 'C' => 'Children'),
            'required'  => false,
            'expanded' => true,
            'multiple' => true
        ));

My field : 我的领域:

/**
     * @ORM\Column(type="string", columnDefinition="CHAR(1) NOT NULL")
     */
    protected $adult_available;

My form looks good! 我的表格看起来不错! But when I submit I got the ContextErrorException exception 但是当我提交时,我得到了ContextErrorException异常

Thanks! 谢谢!

Try this: 尝试这个:

/**
 * @var array
 *
 * @ORM\Column(name="adult_available", type="simple_array")
 */
private $adultAvailable;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM