2012-05-04 10 views
0

同じフィールドの複数の翻訳を1つのフォームに保存できますか? 私は、名前フィールドを翻訳するために、Behavior Translを持つモデルを持っています。 3つの翻訳(deu、eng、ita)はi18nテーブルに正しく記録されていますが、フィールドは正しく検証されていません!助言がありますか?CakePHP 2&Translate Behavior:1つのフォームに複数の翻訳を保存する

アプリ/モデル/ Category.php

class Category extends AppModel { 
    public $actsAs = array('Translate' => array('name' => 'TranslateName')); 
    public $validate = array(
     'name' => array(
      'notempty' => array(
       'rule' => array('notempty'), 
       'message' => 'Error notempty', 
      ), 
     ), 
    ); 
    ... 

アプリ/ビュー/カテゴリー/ admin_edit.ctp

<?php 
echo $this->Form->create('Category'); 
echo $this->Form->input('Category.id'); 
echo $this->Form->input('Category.name.deu', array('label' => __d('Category', 'Name Deu'))); 
echo $this->Form->input('Category.name.eng', array('label' => __d('Category', 'Name Eng'))); 
echo $this->Form->input('Category.name.ita', array('label' => __d('Category', 'Name Ita'))); 
echo $this->Form->end(__d('app', 'Submit')); 
?> 

アプリ/ビュー/コントローラ/ CategoriesController.php

if ($this->Category->save($this->request->data)) { 
    $this->Session->setFlash(__d('Category', 'The category has been saved')); 
} else { 
    $this->Session->setFlash(__d('Category', 'The category could not be saved. Please, try again.')); 
} 

答えて

関連する問題