2010-07-28 64 views
1

我想使用symfony显示组合框。在CountryForm.php中我创建了一个小部件:提交表单时sfWidgetFormChoice出现'Invalid'错误

$ this-> setWidgets(array('country'=> new sfWidgetFormChoice(array('choices'=> array()))));

此验证为:

$这个 - > setValidators(阵列( '国家'=>新sfValidatorChoice(阵列( '选择'=>阵列(array_keys($国家))))));

我收到此错误为“无效”此组合框。有关于此的任何想法?在此先感谢..

回答

2

array_keys返回一个数组。试试:

$this->setValidators(array(
    'country' => new sfValidatorChoice(array(
     'choices' => array_keys($countries) 
)) 
));