Tuesday, April 27, 2010

Re: automagic select boxes for "belongsto" relations

If concatenating or calculating fields etc. you will then need to use
Set::combine to reformat the array so the form helper can use it.

$data = $this->Artist->find(
'all',
array(
'fields' => array(
"concat(Artist.first_name,' ',Artist.last_name) as name"
)
)
);

Would then need the following to set the array in the right format:

$this->set('artists', Set::combine($data, '{n}.Artist.id', '{n}.
0.name'));

HTH

Paul

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: