Had yesterdey something similar so I hope i can help you:

new sfWidgetFormDoctrineChoice(array(
                                                            'model'      =>
'Department',
                                                            'multiple'   =>
true,
                                                            'method'     =>
'getUsersKeyValue',
                                                            'key_method' =>
'getName', //name of the department
                                                            'table_method'
=> 'findAll'
                                                          )
                                                      )

implement in the Department model de method getUsersKeyValue returning an
asociative array  (userkey => username) of the users.

for example:

public function  getUsersKeyValuer() {
       $keyValuePairs = array();

       foreach ($this->getUsers() as $user)
          $keyValuePairs[$user->getId()] = $user->getName();

       return $keyValuePairs;
 }

I hope it works

On Thu, Jun 17, 2010 at 1:23 PM, B.O.G <[email protected]> wrote:

> Hello!!
>
> I have two tables:
>
> Department:
> id
> name
> abrev
>
> sfGuardUserProfile:
> id
> department_id
> name
> ....
> ...
>
> Then, what i want to do is an array like this:
> $choices = array(
>  'Europe'  => array('France' => 'France', 'Spain' => 'Spain', 'Italy'
> => 'Italy'),
>  'America' => array('USA' => 'USA', 'Canada' => 'Canada', 'Brazil' =>
> 'Brazil'),
> );
>
> but with my data from tables before:
> $choices = array(
>    'department1 => array('profile_id' => 'profile_name'),
>    'department2 => array('profile_id => 'profile_name'))
>
> I mean, group the employees (in the profile) by theirs department.
> Can i do this with one single doctrine query ???? How can i do
> this????
>
> Thanks
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-users%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to