Howdy all,
I'm trying to find a way to achieve a custom value in the result of
find('list') method, with the aim of using it as a <select> in a form.
My table (among other) has two fields:
cust_short_name (char), and
cust_no (int)
I tried with adding an afterFind callback in the model, which gave me
the required output.
function afterFind($results)
{
foreach ($results as $key => $val) {
$results[$key]['Customer']['cust_number_name'] =
$results[$key]['Customer']['cust_number'] . ' - ' .
$results[$key]['Customer']['cust_short_name'];
}
return $results;
}
The result can be read from the array under the 'cust_name_number' key
and looks like '13324 - John's Shop'. Cool.
But when i tried calling find('list') with 'fields' =>
array('cust_name_number') parameter, cake spits out an error that the
field 'cust_name_number' is not found. It's clear to me that 'fields'
parameter is added to the query sent to db, not the array output.
Is there any way to get a concatenated field in the output of the
find('list') method without querying views inside the db?
Or am I just doing something wrong?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---