Nope, containable isn't working either. The following code (I'm now
including my prefixes for my plugin. The name of my plugin is Cms):
$this->CmsPage->CmsLayout->Behaviors->attach('Containable');
$this->CmsPage->CmsLayout->contain('CmsTemplate');
debug($this->CmsPage->CmsLayout->findById($id));
exit;
Produces this error:
Warning (512): Model "CmsLayout" is not associated with model
"CmsTemplate" [CORE/cake/libs/model/behaviors/containable.php, line
340]
In my cms_templates table, there is a field called cms_layout_id so
this should work.
In my models I have $hasMany = 'CmsTemplate' for CmsLayout.php and
$belongsTo = 'CmsLayout' in my CmsTemplate.php.
Any thoughts?
On Oct 7, 4:15 am, brian <[email protected]> wrote:
> On Mon, Oct 5, 2009 at 8:45 PM, MeanStudios <[email protected]> wrote:
>
> > Greetings,
>
> > I'm not sure if this is a bug or not but here it goes. If I have 3
> > models (Layout, Template, Page). Layout has many Page and Template.
> > Page and Template have only one Layout. If I am in the
> > PagesController and I do something like $this->Page->Layout->findById
> > ($id) it should return an array with with Layout data as well as all
> > the templates and pages that are related to the passed layout id,
> > correct? Well it's not. The only way I can get that data is if I do
> > a bind right before the findById() like so
> > $this->Page->Layout->bindModel(array('hasMany' => array('Template' =>
> > array('className' => 'Template'))));
> > $this->Page->Layout->findById($id);
>
> > That will return an array of the Layout Data as well as an array of
> > all the templates that Layout has associated to it.
>
> > Yes, my $hasMany and $belongsTo definitions are setup correctly
> > because I can go into the LayoutsController and just do:
> > $this->Layout->findById($id);
> > and it will return all the data it's supposed to.
>
> > Yes I am using prefixes for my plugin controllers, models, views,
> > etc. It's just less confusing if I don't do it here.
>
> > I'm pretty sure that I don't need the bind when not working inside a
> > template but inside a regular controller.
>
> If the associations are correct, that would seem odd. Can you try it
> using Containable?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---