I figured it out!!!! If you are in the inside-crowd and can add documentation for this problem, please do, assuming I am correct.
I found:
A Model hasAndBelongsToMany association requires an EXPLICIT SETTING ['with' => false] whenever the expectation is that the association model is to be constructed using the Subclass Class constructor versus dynamically constructed using AppModel.
In my case, I added MyModel to the Controller $uses array. However, there was another MyRelatedModel in the Controller $uses array that was registered by ClassRegistry::init prior to MyModel. When MyRelatedModel was initialized, it created a dynamic instance of MyModel. As a result, when ClassRegistry::init was called with MyModel there was already an object registered with the same ClassName and therefore was not recreated. I had to add 'with' => false to the MyRelatedModel settings for MyModel to ensure AppModel is not used to construct the object.
Please confirm receipt of this information.
Sincerely,
Charles A Beasley
On Thu, Feb 26, 2015 at 3:15 AM, José Lorenzo <jose.zap@gmail.com> wrote:
That means your class is not being loaded, check you wrote the right class name, and that it was placed in the right folder with the correct file name.If your model is in a plugin, make sure it was loaded using the plugin notation.
On Thursday, February 26, 2015 at 9:06:57 AM UTC+1, Charles Beasley wrote:I have a model that extends AppModel and overrides the constructor, but the constructor never gets called... instead only the AppModel constructor is called.
As a result, the belongTo and other associations defined in the class are empty. However, if I add the following LINE before calling "find", the Model has the defined belongsTo associations and works without error.
if ( empty($this->ctl->LocationPackage->belongsTo) ) die('LocationPackage Model is corrupted');
Does anyone have any suggestions as to why the above LINE causes the Model to be constructed from the Subclass rather than only call the AppModel constructor?
Thanks in advance.
Sincerely,
Charles
--
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Like Us on FaceBook 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment