Hi,
I thought I'd ask this here. (see why below)
How do I write afterFind() to modify a field.

For example just something simple like this (just an example):

function afterFind($data) {
    foreach ($data as $key => $val) {
        if ( isset($val[$this->alias]['name']) ) {
            $data[$key][$this->alias]['name2'] = $val[$this->alias]
['name'];
        }
    }
    debug($data);
    return $data;
}


What I want to know is how to pick out the field from the passed data
array. There are so many different ways the data is formatted that I
end up with a quite messy series of for's and if's and I still don't
fell 100% sure I got them all. I feel there must be some sure-fire way
to write these.

The Cookbook is not complete compared to what I get.
http://book.cakephp.org/view/681/afterFind

The API does not mention much about this.

I did not find any test in the core that helped me.

I did not find anything on Google that dealt with anything but basic
"primary" data.

I noticed that sometimes afterFind() is called more than once with
different data-structure each time. I asked about that here:
http://groups.google.com/group/cake-php/browse_thread/thread/c83e5f40ac861caa/1d88bdb31fa3d12f

I'd love some clarification of this callback. Thans in advance.
/Martin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to