]> _ Git - cubist_cms-back.git/commitdiff
#2843
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 21 Jun 2019 12:55:25 +0000 (14:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 21 Jun 2019 12:55:25 +0000 (14:55 +0200)
src/app/Magic/Fields/Field.php
src/app/Magic/Models/CMSPage.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/app/Template/TemplateAbstract.php

index 528db59ccb5c6150e77940b3d9701e01e2dc293d..abc5917b3f568ba80eab5a41df80118a6a7f9539 100644 (file)
@@ -74,7 +74,7 @@ class Field implements \ArrayAccess
 
     public function getDatabaseType()
     {
-        if ($this->_translatable) {
+        if ($this->getAttribute('translatable')) {
             return 'text';
         }
         return $this->_databaseType;
index 2f02c1a7dceefd12b13f67b21de34773f62d611b..1276e8e364aebbb4bca49eda2e0a3d5ec710e461 100644 (file)
@@ -54,6 +54,7 @@ class CMSPage extends CubistMagicModel
             'default' => '0',
             'label' => __('Status'),
             'options' => ['0' => __('Offline'), '1' => __('Published')],
+            'translatable' => true,
             'tab' => 'Informations principales',
         ]);
         $this->_seo();
@@ -148,7 +149,9 @@ class CMSPage extends CubistMagicModel
             return;
         }
         foreach ($fields as $field) {
-            $this->addFakeField($field);
+            $attr = array_merge($this->defaultFieldAttributes, $field);
+
+            $this->addFakeField($attr);
         }
 
         $controller->updateFieldsFromModel();
index 8a8338db2c58f19b75860a670448bd4035679d42..31073eaefd758390e13670a4cdd7afdf365d47ee 100644 (file)
@@ -211,11 +211,15 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             if (!in_array($store_in, $this->fillable)) {
                 $this->fillable[] = $store_in;
             }
-            if (!isset($this->casts[$store_in])) {
-                $this->casts[$store_in] = 'array';
+
+            $this->casts[$store_in] = 'array';
+
+            if ($field->getAttribute('translatable')) {
+                $this->fillable[] = $store_in;
+                $this->translatable[] = $store_in;
             }
 
-            $this->fakeColumns[$store_in] = true;
+            $this->fakeColumns[] = $store_in;
         } else {
             if ($field->getAttribute('fillable')) {
                 $this->fillable[] = $name;
@@ -226,9 +230,6 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             if ($field->getAttribute('hidden')) {
                 $this->hidden[] = $name;
             }
-            if ($field->getAttribute('translatable')) {
-                $this->translatable[] = $name;
-            }
             if ($field->getAttribute('cast', false) !== false) {
                 $this->casts[$field->getAttribute('name')] = $field->getAttribute('cast');
             }
@@ -237,6 +238,10 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             }
         }
 
+        if ($field->getAttribute('translatable')) {
+            $this->translatable[] = $name;
+        }
+
 
     }
 
index d264536ad4f5fcfef0f31b7f6eb58b6fd6fd1135..885d34e323411a1ec515f66b2985b84c30893453 100644 (file)
@@ -12,7 +12,7 @@ class TemplateAbstract
      */
     protected static $_templates = null;
 
-    protected $defaultFieldAttributes = ['translatable' => true];
+    protected $defaultFieldAttributes = [];
 
     protected $_fields = [];