Thanks Jamie,

Good to know it wasn't because I stuffed up or there was a proper fix
that is practicable to apply.

I have just spun through the after find code from expandable like you
said,

foreach ($content['Article'] as $i => $item) {
  foreach ($item['ContentField'] as $field) {
  $content['Article'][$i][$field['key']] = $field['val'];
 }
}

in my controller.  worse things happen at sea,

Thanks. Will.

On Mar 12, 4:25 am, Jamie <jamie....@gmail.com> wrote:
> Hi Will,
>
> This isn't a bug with the behavior, but a 'feature' of CakePHP.
> Basically, behavior and model callback methods only run for the main
> model of a find query. So behavior methods and regular callbacks
> (beforeFind, etc.) for any associated models - HABTM, hasMany, hasOne
> - are ignored.
>
> There's a ticket for this in the CakePHP Lighthouse project that has
> some good information on why this is the way it 
> is:http://cakephp.lighthouseapp.com/projects/42648/tickets/95-afterfind-...
>
> Basically, the problem runs quite deep and isn't really fixable
> without a large-scale change to the Model class. To fix the issue in
> your case, you'll have to either run a separate query to fetch the
> related Article records, or use the Expandable code after the fact to
> convert the fields manually.
>
> - Jamie
>
> On Mar 10, 11:52 pm, "#2Will" <willjbar...@gmail.com> wrote:
>
> > Hi,
> > I have a model with the expandable behaviour from debuggable, and its
> > working great to add meta data to my content rows.
>
> > When I add related content via a habtm relationship, the expanded
> > fields arn't available.
>
> > Has anyone else found this problem, and maybe an easy fix?
>
> > so my contents table has this:
>
> > var $hasAndBelongsToMany = array(
> >                 'Article' => array(
> >                         'className' => 'Content',
> >                         'joinTable' => 'articles_editions',
> >                         'foreignKey' => 'edition_id',
> >                         'associationForeignKey' => 'article_id',
> >                         'unique' => true,
> >                         'order' => 'ArticlesEdition.id',
> >                 )
> >         );
>
> > which brings the related "articles" contents but without the meta
> > fields brough in by expandable.
>
> > Thanks for any help,
>
> > Will

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to