2012-05-04 106 views
0

它的可能性保存同一領域的多個翻譯在一個單一的形式? 我有一個行爲模型翻譯名稱字段。這三個翻譯(deu,eng,ita)被正確記錄在i18n表格中,但該字段未被正確驗證!有什麼建議麼?CakePHP 2&翻譯行爲:保存多個翻譯在一個單一的形式

應用/型號/ 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.')); 
} 

回答