mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
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:
parent
ed4493da0c
commit
1c0b6c076a
1 changed files with 10 additions and 0 deletions
|
@ -393,6 +393,16 @@ class TranslateBehavior extends ModelBehavior {
|
||||||
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
|
$conditions = array('model' => $model->alias, 'foreign_key' => $model->id);
|
||||||
$RuntimeModel = $this->translateModel($model);
|
$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) {
|
foreach ($tempData as $field => $value) {
|
||||||
unset($conditions['content']);
|
unset($conditions['content']);
|
||||||
$conditions['field'] = $field;
|
$conditions['field'] = $field;
|
||||||
|
|
Loading…
Add table
Reference in a new issue