The format of the `$results` array in `afterFind` varies, a lot, depending on circumstance.
Your best bet is to do a debug($results) inside `afterFind` to see exactly what structure the data is in and act accordingly. There was another thread on this recently. Your `afterFind` code must cope with the different array structures. Other thread is here: http://groups.google.com/group/cake-php/browse_thread/thread/32ab9f8baed4a05a/062678e92b080f18 hth grigri On Jan 9, 3:21 pm, Ernesto <[email protected]> wrote: > Hello. > > i have 2 models, linked together by a HABTM relationship. > The 2nd model has a function that formats some fields after the data > is loaded. > Why is this function not working if i load data from the HABTM > relationship? > is there any better way to make this work? > > Here's an example > > NOTE: this code is for example purpose only. Don't look @ typos :) > > class Car extends AppModel { > var $name = "Car"; > > var $hasAndBelongsToMany = array( > "Passenger" => array( > "className" => "Passenger" > ) > ); > > } > > class Passenger extends AppModel { > var $name = "Passenger"; > > function afterFind($results, $primary = false) { > $results["Passenger"]["Name"] = > strtoupper($results["Passenger"] > ["Name"]); > return $results; > } > > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
