Hello. I'm building an multilingual website in CakePHP 2.0.5 with the use of I18n.
My question is: how can I define (in model class) validation rules, so they apply to specified language version (locale)? I have an i18n table, "languages" table (id,code), "subpages" table (id,created) While adding new subpage (or editing a subpage) I want to display fields for title and content in all the language versions at one form. The simple view ($langs is the list of languages from "languages" table): <?php echo $this->Form->create('Subpage',array('url'=>'/admin/subpages/ add'))?> <table cellspacing="0" cellpadding="0" class="table"> <?php foreach($langs as $l):?> <tr><td colspan="2">Language: <?php echo $l['Language']['code']?></ td></tr> <tr><td>Title</td> <td><?php echo $this->Form->text('Subpage.title.'.$l['Language'] ['code'])?> <?php echo $this->Form->error('title')?> </td> </tr> <tr><td>Content</td> <td><?php echo $this->Form->textarea('Subpage.content.'. $l['Language']['code'],array('class'=>'ckeditor'))?></td></tr> <?php endforeach;?> </table> <?php echo $this->Form->submit('Add subpage',array('class'=>'submit','div'=>false))?></div> <?php echo $this->Form->end();?> The part of code in controller's action: if($this->request->is('post')) { if(!empty($this->request->data)) { $this->Subpage->set($this->request->data); if($this->Subpage->validates()) { $this->Subpage->create(); $this->Subpage->save($this->request->data); } } } It works fine and on add subpage action it entries both translations to i18n table. The problem is, I have a validate variable defined for Subpage model like this: public $validate = array ( 'title' => array( 'minlength' => array( 'rule' => array('minLength', '1'), 'message' => 'Title cannot be empty', ), 'maxlength' => array( 'rule' => array('maxLength', '40'), 'message' => 'Title cannot be longer than 40 characters', ), 'chars' => array( 'rule' => array('custom', '/^[A-Za-ząĄćĆęĘłŁńŃóÓśŚźŹżŻ0-9\ ]* $/'), 'message' => 'Title can contain only letters, numers and spaces ', ), ), If I enter an unaccepted string into the title field in ONE of the language versions and submit form, both fields (in both languages) are marked as invalid and for both fields the error is being displayed (apart from the fact that second field is filled correctly). Does anyone know how to fix this or what should the $validate var look like? Thank you in advance for help. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php