To keep your controllers skinny, the following approach (using pretty
much the same method does the trick):
http://teknoid.wordpress.com/2008/09/04/findlist-with-three-or-combined-fields/

Also, once you retrive the results and set them to a certain variable
in the controller, there is no need to pass the array to the view.
CakePHP will handle it for you... (another shameless self-promo :) )
http://teknoid.wordpress.com/2008/08/08/automagical-selects-or-checkboxes/


On Oct 28, 9:29 am, "Liebermann, Anja Carolin"
<[EMAIL PROTECTED]> wrote:
> Hi Mario,
>
> I have similar situations in my application and I guess there is no automatic 
> way to do it.
>
> So what I do is get the data wth all fields and loop through them and create 
> another array with value = id and shown sring firstname + family name.
>
> If there is a more elegant solution I don't know it.
>
> Anja
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von mario
> Gesendet: Sonntag, 26. Oktober 2008 16:09
> An: CakePHP
> Betreff: concatenation in find('list')
>
> Hi guys,
>
> I have this following code snippet from my controller:
>
> $salespeople = $this->Campaign->Salesperson->find('list',
>                                   array('order' => 'Salesperson.firstname 
> ASC',
>                                           'fields' => array('Salesperson.id', 
> 'Salesperson.firstname')));
>
> In my view, I have this following line:
>
> echo $form->input('salesperson_id');
>
> This codes would create a combobox in my view that would have a key: 
> salesperson.id and value: salesperson.firstname
>
> Now here is what I want to do:
>
> I also have a field 'lastname' under my salespeople table and I want it to be 
> concatenated to the salespersons'
> firstname (with a space between the firstname and lastname).
>
> I can't just have the firstname in my combobox because there is a high 
> possibility that there would be duplicates for firstnames.
> It would be better if firstname and lastname would be displayed in my view's 
> combobox and still would match to a corresponding salesperson.id.
>
> Is there a way to do this?
>
> Thanks,
> Mario
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to