Search code examples
symfony1doctrinesfguard

symfony drop down with sfguardusers from a specific group


Using sfguard and doctrine I have the following groups:

Managers Chefs Waiters

I have a module for receipts and in the form I want to select a waiter. The default ReceiptForm.class.php populates the fields:

$this->setWidgets(array(
    'id'               => new sfWidgetFormInputHidden(),
    'sf_guard_user_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => true)),
);

Its fine as it grabs all the users but how do I configure it to only have users from the group "waiters" or id=3 in the database?


Solution

  • You can pass a Doctrine_Query object to the widget with the query option as explained in Chapter 10 - Forms for Propel. It' the same thing using Doctrine.