【问题标题】:'Invalid' error for sfWidgetFormChoice when form is submitted提交表单时 sfWidgetFormChoice 出现“无效”错误
【发布时间】:2010-07-28 04:21:02
【问题描述】:

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

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

对于这个验证器为:

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

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

【问题讨论】:

    标签: php symfony1 symfony-forms


    【解决方案1】:

    array_keys 返回一个数组。试试:

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

    【讨论】:

      猜你喜欢
      • 2011-07-28
      • 2014-02-25
      • 2018-11-24
      • 2017-08-24
      • 2011-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多