Monday, December 17, 2012

Re: Translate on BelongsToMany

It's not very clear what you're doing. Can you post the model
associations and the column names for each table?

But are you certain that you want to use HABTM? Can different
Categories share a SubCategory? If a SubCategory can only belong to
ONE Category then you should use:

Category hasMany SubCategory
SubCategory belongsTo Category

Better:

Category model:

public $actsAs = array(
'Tree' => array(
'parent' => 'parent_id',
'left' => 'lft',
'right' => 'rght'
)
);

... And forget about having a separate model for SubCategory.



On Mon, Dec 17, 2012 at 11:33 AM, Carlos Eduardo Sotelo Pinto
<carlos.sotelo.pinto@gmail.com> wrote:
> Dear coders
>
> I have an issue on a project That I am working, I have to models linked
> on a belongsToMany relationship, and both of them are using the
> translate behavior
>
> i18n -> SubCategory [ belongsToMany ] Category <- i18n
>
> Then I need to do a list like
>
> CategryName - SubCategoryName
>
> As you could see I need to concatenate Name field on both models, and
> name field on both models are translated, I mean, both of them name
> fields are on the i18n table, then when I do a
>
> $this->Subcategory->find ('all');
>
> for process and user the fields needed, I could see that Categroy,
> doesnt have the Name field, just Subcategory has the name field
>
> Any suggest
>
> Best Regards
>
>
> --
> Carlos Eduardo Sotelo Pinto
> GNU Linux Admin | PHP Senior Web Developer
> MObil: RPC (Claro)+51, 958194614
> http://www.carlossotelo.com
> Skype: csotelop
> Yahoo: csotelop
> MSN: carlos.sotelo.pinto@gmail.com
> GTalk: carlos.sotelo.pinto@gmail.com
> GPG FP:697E FAB8 8E83 1D60 BBFB 2264 9E3D 5761 F855 4F6B
> GNULinux RU #379182 || GNULinux RM #277661
>
> --
> 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 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.
>
>

--
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 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: