I think he is using the scaffold version which limits the returned fields for the afterSave to look at

On 4/6/06, nate < [EMAIL PROTECTED]> wrote:

It is quite simple.  Let's say you have a model called Person, and you
want to set up a virtual field called "full_name", which will be
comprised of the "first_name" and "last_name" fields.  (I will assume
you're using generateList to create the select list array.)

class Person extends AppModel {

    function afterFind($results) {
         foreach ($results as $key => $val) {
            $results[$key]['Person']['full_name'] =
$val['Person']['first_name'] . ' ' . $val['Person']['last_name'];
        }
        return $results;
    }
}

$this->Person->generateList(null, null, null, null,
"{n}.Person.full_name");

That's all there is to it.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to