如何在Symfony1中使用sfWidgetFormSelectMany设置所选值?

时间:2016-04-19 06:57:51

标签: symfony1

我想在sfForm中使用sfWidgetFormSelectMany。我在设置select的选项时没有问题,但是如何在加载表单时设置所选的值?

这是我到目前为止sfWidgetFormSelectMany的代码:

$choices = $this->getScopes();

$this->widgetSchema['application_scopes'] = new sfWidgetFormSelectMany(array(
  'choices' => $choices
));
$this->validatorSchema['application_scopes'] = new sfValidatorChoiceMany(array(
  'choices' => array_keys($choices)
));

1 个答案:

答案 0 :(得分:1)

所以,我必须自己回答这个问题。有时,最好的方法是提出问题以找到答案; - )

由于我在我的表单类中,我可以像这样设置值:

$this->setDefault('application_scopes', array('this','that'));