,該模型來這裏如何更新翻譯CakePHP的,但不是我加入翻譯行爲模型主表
App::uses('AppModel', 'Model');
class Category extends AppModel
{
public $hasMany = "Product";
public $validate = array(
'name' => array(
'rule' => 'notEmpty'
)
);
public $actsAs = array(
'Translate' => array(
'name','folder','show'
)
);
public $name = "Category";
public $translateModel = 'KeyTranslate';
}
而且繼承人的控制器更新模型
public function admin_edit_translate($id,$locale)
{
$this->Category->locale = $locale;
$category = $this->Category->findById($id);
if ($this->request->is('post') || $this->request->is('put')) {
$this->Category->id = $id;
if ($this->Category->save($this->request->data)) {
$this->Session->setFlash('Category translate has been updated');
//$this->redirect(array('action' => 'edit',$id));
} else {
$this->Session->setFlash('Unable to update category');
}
}
if (!$this->request->data) {
$this->request->data = $category;
}
}
我的問題是我在類別數據庫中有一個名稱字段,當我更新或創建一個新的翻譯時,它將使用翻譯後的值進行更新。我如何避免
這是錯誤的方式$這個 - >類別 - > locale = $ locale; – 2013-03-29 10:32:51