I've created first part of my I18n behavior : http://pastie.org/334460
Now lest say i have 2 modes Offer and RoomFeature. Offer HABTM
RoomFeture HABTM Offer. Now in my controller i have:
public function test(){
$this->Offer->find('all', array(
'order' => array('Offer.object_description' => 'DESC'),
'fields' => array('object_description'),
'contain' => array('RoomFeature' => array('fields' => 'name'))
));
}
My offers table
- id
- object_description_pol
- object_description_eng
My rooms table
- id
- name_pol
- name_eng
My default language is pol so in code above i want to get :
- Offer.object_description_pol
- RoomFeature.name_pol
If In my behavior in beforeFind method i'll add var_dump($model->name)
i can see that it's been called only for Offer model. That's why names
of columns from RoomFeature model are not changed and i get error
"column name is not specified".
I think i have to add in localizeQuery method smth like that :
if (isset($model->hasAndBelongsToMany)) {
foreach ($model->hasAndBelongsToMany as $name => &$relation) {
if (isset($model->$name->Behaviors->I18n)) {
// I DONT KNOW WHAT PUT HERE
}
}
}
btw. Behavior is working fine for Offer model, all columns names are
change fine.
Behavior config for Offer model:
public $actsAs = array('I18n' => array('fields' => array
('object_description', 'short_object_description')));
Can anybody tell me how to 'init' behavior for every model that is
specified in query ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---