Sunday, November 17, 2013

Related model and translate behavior: How to get the results?

I have the 'Post' and 'Attachment' models, through which I need to save and display the results in multiple languages. Model 'Post' hasmany 'Attachment', the latter each have a caption fields, which should be translated into different languages.

Saving the translated value of these models work properly.

Problem is when displaying a localized version of the Post and related attachments, I can not get the correct translation of the caption fields (in this case, the displayed data is stored in the attachments table)!

You probably know this is not a new problem, I looked at a lot of google results, but I can not now find a solution. Help, I tear my hair out!

Thank you in advance for your help!

find code:

$this->Post->locale = $locale;
$this->Post->Attachment->locale = $locale; //??

$options = array('conditions' => array('Post.' . $this->Post->primaryKey => $id));
$this->Post->find('first', $options);
....

--
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/groups/opt_out.

No comments: