UPDATE: I also have to use $array[0]['Model__i18n_translated_field'] in normal (not forms) view files.
On Wednesday, October 1, 2014 9:32:05 AM UTC+2, Lucky1968 wrote: > > Hi, > > I'm using i18n in my application and it seems that in certain views I can > use $array['translated_field'] as in other views I need to use > $array[0]['Model__i18n_translated_field'] to get the same information > coming from the same find in the same model. > > Can anyone tell me why this is? > > This is my code: > > MY MODEL (SettingsSite.php): > <code> > class SettingsSite extends AppModel { > > public $actsAs = array( > 'Translate' => array( > 'slogan' > ) > ); > > ... > > public function first_site() { > return $this->find('first', array('recursive' => -1)); > } > > } > </code> > > MY VIEWS: > <code> > App::import('Model', array('SettingsSite')); > $settingsSiteObj = new SettingsSite(); > $first_site = $settingsSiteObj->first_site(); > </code> > > RESULTS: > In (almost) all my view files within my main application and in all my > view files in plugins I get the results like this: > > array( > 'SettingsSite' => array( > ... > 'locale' => 'eng', > 'slogan' => 'Translated Slogan' > ) > ) > > But in (apparently form-) view files in my main application I get the > results like this: > > array( > 'SettingsSite' => array( > ... > 'locale' => 'eng', > 'slogan' => '' > ), > (int) 0 => array( > 'SettingsSite__i18n_slogan' => 'Translated Slogan' > ) > ) > > As said, all the code in the view files is identical and therefor pointing > to the same function in the same model. And the a.m. result code is the > result of debug() within the models function, so IMHO, shouldn't be > influenced by anything else in the view file. > > Can someone tell me why this is? > > Thanx. > > Luc > -- 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+unsubscr...@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/d/optout.