Monday, November 2, 2009

Containable together with Translate Behavior

Hi guys,

i'm trying to combine Containable and Translate Behavior.

My setup:

Models:
A hasMany B
A Translate = 'field_a'
B belongsTo A
B Translate = 'field_b'

Controllers:
A->contain('B');
A->read(null, $id);

AppModel:
beforeFind:
$this->locale = 'de_de';
beforeSave:
$this->locale = 'de_de';

So what I expected was translated content for associated datasets of B
in reading A. But what automagically happens with field_a from
instance A, doesn't appear with field_b from instance B. I checked the
sql command. This seems to be correct.

SELECT B.*, I18n__field_b.content FROM b AS B LEFT JOIN i18n AS
I18n__field_b ON (B.id = I18n__field_b.foreign_key AND
I18n__name_field_b.model = B AND I18n__field_b.field = field_b) WHERE
a_id = 1 AND I18n__field_b.locale = de_de

Any suggestions? I don't know how to use it together. Of course I can
make the find call manually for B, but I wanted to use the normally
really good Containable Behavior.

Thanks in advance.
Marco
--~--~---------~--~----~------------~-------~--~----~
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
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: