Entitytype对象为simple_array

时间:2016-01-06 17:45:19

标签: symfony doctrine-orm

您好我有这个EntityType

 ->add('emotions', EntityType::class, array('class' =>   'MovieBundle:Emotion', 'choice_label'=>'emotion', 'multiple' => true, 'expanded' => true))

我尝试使用属性Emotions

将其保留为数据库
/**
 * @var array
 *
 * @ORM\Column(name="emotions", type="array")
 * 
 */
private $emotions;

所以在db中我得到了这个:

0:43: “教义\共同\类别\ ArrayCollection的”:1:{S:53: “教义\共同\类别\ ArrayCollectionelements”;一个:1:{I 0,O:26:“MovieBundle \实体\情感 “:2:{S:30:” MovieBundle \实体\ Emotionid “; I:1; S:35:” MovieBundle \实体\ Emotionemotion “; S:6:” 愉快的“;}}}

非常难看。所以尽量简化并将其改为:

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

不幸的是我收到了一个错误 警告:implode()传递的参数无效。 尽管我在构造中定义了一个arrayCollection,但我仍然有这个错误

0 个答案:

没有答案