From 5f020f28245653c91c208220eed8fe015a4317e2 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 3 Jul 2019 21:09:16 +0200 Subject: [PATCH] #2843 --- src/app/Magic/Fields/CMSTemplate.php | 1 + src/app/Magic/Models/CMSPage.php | 12 +++++++++++- src/app/Magic/Models/CubistMagicAbstractModel.php | 7 ++----- src/resources/views/fields/tags.blade.php | 5 ++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/Magic/Fields/CMSTemplate.php b/src/app/Magic/Fields/CMSTemplate.php index b318ac9..244e480 100644 --- a/src/app/Magic/Fields/CMSTemplate.php +++ b/src/app/Magic/Fields/CMSTemplate.php @@ -11,6 +11,7 @@ class CMSTemplate extends SelectFromArray { protected $_allowNull = false; + protected $_translatable = false; protected function _postSetAttributes() { diff --git a/src/app/Magic/Models/CMSPage.php b/src/app/Magic/Models/CMSPage.php index 64ede1a..e48bb42 100644 --- a/src/app/Magic/Models/CMSPage.php +++ b/src/app/Magic/Models/CMSPage.php @@ -28,6 +28,7 @@ class CMSPage extends CubistMagicNestedModel 'type' => 'CMSTemplate', 'label' => 'Template', 'column' => true, + 'translatable' => false, 'tab' => 'Informations principales', ]); @@ -35,6 +36,7 @@ class CMSPage extends CubistMagicNestedModel 'label' => trans('Page name'), 'type' => 'Text', 'column' => true, + 'translatable' => false, 'hint' => trans('for admin use'), 'tab' => 'Informations principales', ]); @@ -149,9 +151,17 @@ class CMSPage extends CubistMagicNestedModel } } - public function update(array $attributes = [], array $options = []) + public function create(array $attributes = []) { + $this->useTemplate($attributes['template']); + return parent::create($attributes); + } + public function update(array $attributes = [], array $options = []) + { + $this->useTemplate($attributes['template']); return parent::update($attributes, $options); } + + } diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 060336f..de85ba7 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -1,6 +1,5 @@ $attribute) { if (is_array($attribute) || is_object($attribute)) { $res[$key] = json_encode($attribute); @@ -462,7 +460,6 @@ class CubistMagicAbstractModel extends Model implements HasMedia public function update(array $attributes = [], array $options = []) { - return $this->updateTranslations($this->_prepareData($attributes), $options); } diff --git a/src/resources/views/fields/tags.blade.php b/src/resources/views/fields/tags.blade.php index 41e229b..4ebc536 100644 --- a/src/resources/views/fields/tags.blade.php +++ b/src/resources/views/fields/tags.blade.php @@ -1,6 +1,9 @@ @php - $values=json_decode(old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '[]'); + $values=old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '[]'; if(!is_array($values)){ + $values=json_decode($values); + } + if(!$values){ $values=[]; } $normalizedValues=[]; -- 2.39.5