1

我想使用 symfony 显示组合框。在 CountryForm.php 中,我创建了小部件:

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

对于这个验证器:

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

我收到此组合框的“无效”错误。有什么想法吗?提前致谢 ..

4

1 回答 1

2

array_keys返回一个数组。尝试:

$this->setValidators(array(
  'country' => new sfValidatorChoice(array(
      'choices' => array_keys($countries)
  ))
));
于 2010-07-28T12:13:53.903 回答