3logy
3logy

Reputation: 2712

How to pass a method with parameters as sfWidgetFormPropelChoice(Symfony) option?

I building a Form with widgets. One of them is a Multichoices Form, that i build using sfWidgetFormPropelChoice. Into my customForm.class.php i have this:

customForm.class.php:

class customForm extends BaseCustomForm{
  public function configure(){
   ....
   $this->setWidgets(array(
    ...
    'myMultiChoice'=>new sfWidgetFormPropelChoice(array('model'=>'custom', 'method'=>'getLotsOfThings'));
    ...
  ));
 }
}

The option 'method' is getting a method 'getLotsOfThings' which dont have any parameters. How can i pass instead this method with parameters?

I try 'method'=>'getLotsOfThings('.$value.')' but this dont work!

Upvotes: 0

Views: 872

Answers (1)

j0k
j0k

Reputation: 22756

You should have to use the criteria option instead (see the code) which give you the ability to have a complex query to retrieve items.

For example:

$c= new Criteria();
$c->add(CountryPeer::idcontinent, 1);

$this->widgetSchema['departement_id'] = new sfWidgetFormPropelChoice(array(
  'model'     => 'Country', 
  'add_empty' => true, 
  'criteria'  => $c
));

Give the criteria as an option to the Form when you create it.

Upvotes: 1

Related Questions