Sunday, October 26, 2008

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: