2010-07-28 65 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) 
)) 
));