我正在做应用程序,在其中我使用SQL,我想将复选框值保存在一个列中。我是这样做的:
/**
* @Assert\NotBlank(
* message="please select!")
* @Assert\NotNull(
* message="please select!")
* @Assert\Range(min=0, max=9)
* @ORM\Column(type="integer")
*/
protected $ingredients;
public static function getIngredientsOptions(){
return array('cheese','tomatoes','salami','onions','mushroom','bacon','ham','vegetables','peppers','olives');
}但我得到的错误表明我有选择错误,我认为问题是与复选框。这是对的吗?你能帮我解决这个问题吗?
发布于 2015-12-07 06:36:29
可以将列类型更改为“数组”,如下所示:
@ORM\Column(name="ingredients", type="array", nullable=true)这将导致一个包含注释"(DC2Type:array)“的长文本字段,因此Doctrine知道如何处理它。它将存储序列化的数组。
这可能是你想要的。如果没有,请张贴更多的代码,你的设置者和控制器,其中使用的表单,以及错误信息。
https://stackoverflow.com/questions/34123940
复制相似问题