http://teknoid.wordpress.com/2008/09/04/findlist-with-three-or-combined-fields/ http://bakery.cakephp.org/articles/view/add-formatted-lists-to-your-appmodel
On Jan 6, 9:57 pm, Chris Gallop <[email protected]> wrote: > Hi > > I have a model called 'Client' that has a HABTM relationship with > another model called 'Project'. On my project edit view I am using > the FormHelper to create a select box populated by the clients names > so they can be selected and linked to the project. > > However as the client first name and last name are in different > fields. How do I generate a $Client->find call that combines the > first and last names in a 'key' => 'value' type array for the > FormHelper::select to use? Using cake 1.2 > > Currently > // project controller > // need to add code to make "client.firstname" and "client.lastname" > merged into one element in outputted array... > $this->set('clients', $this->Project->Client->find("list", array > ("fields" => array("Client.id", "Client.firstname")))); > > // project edit.ctp > echo $form->select('Client', $clients, null, array('label'=>'Client'), > "Select Client -->"); > > If anything needs more explanation please let me know. Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
