The Translate behavior uses the beforeFind() callback, which sadly is not supported on associated models. Even sadder, there are no plans to fix this.
See https://trac.cakephp.org/ticket/3638 and https://trac.cakephp.org/ticket/1183 No, it doesn't make sense to me either. It looks like the model association code is distributed over both the model and the datasource, and re-coupling them to work properly with behaviors is not going to happen. On Dec 3, 10:43 am, maniuch <[EMAIL PROTECTED]> wrote: > How to fetch translated fields form associated models? > > My Example: > > Models (extrected important parts): > class System extends AppModel { > var $actsAs = array('Translate' => array('name', 'description')); > var $belongsTo = array( > 'SystemType' => array('className' => 'SystemType', > 'foreignKey' > => 'system_type_id', > 'conditions' > => '', > 'fields' => > '', > 'order' => '', > > 'counterCache' => ''), > ); > > } > > class SystemType extends AppModel { > var $actsAs = array('Translate' => array('name')); > var $hasMany = array( > 'System' => array('className' => 'System', > 'foreignKey' > => 'system_type_id', > 'conditions' > => '', > 'fields' => > '', > 'order' => '', > 'limit' => '', > 'offset' => > '', > 'dependent' > => '', > 'exclusive' > => '', > 'finderQuery' > => '', > > 'counterQuery' => ''), > ); > > } > > In SystemsController, scaffolded action index, which uses paginator > doesn't fetch translation in associated models. Result of > print_r($this->paginate()) (extracted): > > Array > ( > [0] => Array > ( > [System] => Array > ( > [id] => 1 > [name] => MySystem > [photo] => > [description] => Super system! > [system_type_id] => 1 > [created] => 2007-11-29 11:41:35 > [modified] => 2007-11-29 11:41:35 > [locale] => pol > ) > > [SystemType] => Array > ( > [id] => 1 > [name] => > [created] => 2007-11-29 11:25:28 > [modified] => 2007-11-29 11:25:28 > ) > > ) > > ) > > Translation of System's field were fetched correctly, while > assoctiated models has empty fields here > > Is it a bug or my missunderstanding of how it should work? I'm using > Cake 1.2 nighty build. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
