Sunday, September 23, 2012

2.0 "book" is wrong for "afterFind" callback

The 2.0 book documentation for "afterFind" is either wrong or it's missing information. The example code...

public function afterFind($results, $primary = false) {      foreach ($results as $key => $val) {          if (isset($val['Event']['begindate'])) {              $results[$key]['Event']['begindate'] = $this->dateFormatAfterFind($val['Event']['begindate']);          }      }      return $results;  }

...does not work and generates and error.

I added this code to my model and changed the 'Event' index to my model name 'Post' and when you run you get a repeated "index 'Post' not found".

What requirement is missing from the documentation?

Thanks a lot for your help :-)

Mark

--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: