Update afterSave to ensure created entires have all translated fields present

Without all fields being present, find() will be unable to find the
translated records.

Fixes #3009
This commit is contained in:
Thomas von Hassel 2012-07-06 16:28:30 +03:00 committed by mark_story
parent ed4493da0c
commit 1c0b6c076a

View file

@ -392,6 +392,16 @@ class TranslateBehavior extends ModelBehavior {
unset($this->runtime[$model->alias]['beforeValidate'], $this->runtime[$model->alias]['beforeSave']);
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
$RuntimeModel = $this->translateModel($model);
$fields = array_merge($this->settings[$model->alias], $this->runtime[$model->alias]['fields']);
if ($created) {
foreach ($fields as $field) {
if (!isset($tempData[$field])) {
//set the field value to an empty string
$tempData[$field] = '';
}
}
}
foreach ($tempData as $field => $value) {
unset($conditions['content']);