]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jul 2019 19:09:16 +0000 (21:09 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 3 Jul 2019 19:09:16 +0000 (21:09 +0200)
src/app/Magic/Fields/CMSTemplate.php
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/views/fields/tags.blade.php

index b318ac98c6b49ef4c1bf62bc6e0bbc835b33ff63..244e4806acd3238a67373c2020669e2ba33f1b86 100644 (file)
@@ -11,6 +11,7 @@ class CMSTemplate extends SelectFromArray
 {
 
     protected $_allowNull = false;
+    protected $_translatable = false;
 
     protected function _postSetAttributes()
     {
index 64ede1a7bf85b869a65fd2163c3d05dd43a0fdb9..e48bb425461b33d47bde7e9b6f77b02921a4aee1 100644 (file)
@@ -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);
     }
+
+
 }
index 060336f734725314ae9a3206527d207661710a37..de85ba7bc76977f4fcae4c94247a179a9786685e 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 
-
 namespace Cubist\Backpack\app\Magic\Models;
 
 use Backpack\CRUD\CrudTrait;
@@ -447,9 +446,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
     protected function _prepareData($attributes)
     {
-        print_r($attributes);
-        $attributes = Json::decodeRecursive($attributes, Json::TYPE_ARRAY);
-        $res = [];
+        return Json::decodeRecursive($attributes, Json::TYPE_ARRAY);
+
         foreach ($attributes as $key => $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);
     }
 
index 41e229b614a7ed9125b3c62a5390fc67066f021b..4ebc536fbbcaeb2e614a73311789cd6dc12096f9 100644 (file)
@@ -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=[];