sfValidatorChoice 不适用于多个选择元素,我的代码
$this->form=new MyTestForm();
$options_array=array("php","python","java");
$widgetSchema["my_select"] =new sfWidgetFormChoice(array('choices' => $options_array,'multiple' => true,'expanded' => true ));
$validatorSchema["my_select"] = new sfValidatorChoice(array("choices" =>array_keys($options_array)));
注意:我也尝试过使用 array_keys 并将数组直接传递给 sfValidatorChoice。
当我提交时,它给了我Invalid
错误(选中时)和Required
(未选中时)。参数有错误还是错误?