I'm using cakePHP 2.0 afterFind() callback to perform calculations on database values before it is displayed.
I have three models - Materials, Products and Quotes. Each product has a material and calculations are performed in the Product afterFind callback using this association, specifically with the line: $results[$key]['Product']['material_cost'] = $results[$key]['Product'] ['material_mass'] * $val['Material']['cost']; with $val['Material']['cost'] referring to the associated material. All fine so far. Next I have an afterFind() callback in my Quote model. The quote is associated with a product and the calculations in the quote model are dependant on the calculations in the Product model taking place - specifically the one which referances the material. I can reference the Product model afterfind results in the Quote model afterFind just fine like: $val['Product']['number_tools'] However, now the Product model cannot find the associated material and I get the error: Undefined index: Material [APP/Model/Product.php, line 126]. on line 126 of Product.php is $val['Material']['cost'] How can I get around this problem, it's driving me nuts! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
