我尝试通过Sonata Admin Bundle编辑或添加产品,但验证程序始终拒绝“条件”字段,因为“您选择的值不是有效的选择。”Sonata管理包选择验证错误
管理类
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name', 'text', array('label' => 'Nazwa'))
->add('condition', 'choice', array(
'choices' => Product::getConditions(),
'label' => 'Stan',
));
}
实体
/**
* @Assert\Choice(callback = "getConditions")
* @ORM\Column(type="string", length=10)
*/
protected $condition;
public static function getConditions()
{
return array('new', 'used');
}
编辑:* @ORM \ Column(name =“product_condition”,type =“string”,length = 10) – piotr712
最后编辑不解决主要问题。 – piotr712