我有一个名为'Country'的模型,其数据库表名为'countries'。
国家模型如下:
<?
class Country extends CountryAppModel {
public $name = 'Country';
public $actsAs = array(
'Translate' => array('title', 'description')
);
}
?>
引用CakeBook 2.0(http://book.cakephp.org/2.0/en/core-libraries/behaviors/translate.html)
在为TranslateBehavior定义要翻译的字段时,请务必从已翻译模型的架构中省略这些字段。如果保留字段,则在使用回退区域设置检索数据时可能会出现问题。
所以我删除了标题&amp;来自'countries'表的描述字段。当然,我有命令行创建的i18n表(以确保我有更新版本)
当我尝试使用以下代码进行保存时,没有任何反应,DB中没有保存:
$this->Country->locale = $_POST['language'];
$this->Country->create();
$this->Country->save($this->request->data)
任何想法我做错了什么?
我经历了'Model'类的save()方法并且没有执行任何update / create命令,因为除了primaryKey(id)之外,'countries'表的架构中没有其他字段 - shouldn save()也适用于可翻译字段吗?