我使用小部件构建表单。其中一个是Multichoices表单,我使用 sfWidgetFormPropelChoice 构建。进入我的customForm.class.php我有这个:
customForm.class.php:
class customForm extends BaseCustomForm{
public function configure(){
....
$this->setWidgets(array(
...
'myMultiChoice'=>new sfWidgetFormPropelChoice(array('model'=>'custom', 'method'=>'getLotsOfThings'));
...
));
}
}
选项'method'
正在获取一个没有任何参数的方法'getLotsOfThings'
。我如何通过参数传递此方法?
我尝试'method'=>'getLotsOfThings('.$value.')'
,但这不起作用!
答案 0 :(得分:1)
您必须使用criteria
选项(see the code),这样您就可以使用复杂的查询来检索项目。
例如:
$c= new Criteria();
$c->add(CountryPeer::idcontinent, 1);
$this->widgetSchema['departement_id'] = new sfWidgetFormPropelChoice(array(
'model' => 'Country',
'add_empty' => true,
'criteria' => $c
));
在创建表单时将标准作为选项提供给它。