]> _ Git - cubist_cms-back.git/commitdiff
wip #6571 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Jan 2024 19:17:15 +0000 (20:17 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 4 Jan 2024 19:17:15 +0000 (20:17 +0100)
src/app/CubistCrudPanel.php
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Fields/Field.php
src/app/Magic/Models/CubistMagicAbstractModel.php

index 86439dca92cfad914b0ad60185c4e692e299790b..9b99c5643fd9fbbd2d0ea5da7216278ad25eb208 100644 (file)
@@ -35,7 +35,12 @@ class CubistCrudPanel extends CrudPanel
     public function updateEntry()
     {
         $this->entry = null;
-        return $this->getEntry($this->getCurrentEntryId());
+        return $this->getCurrentEntry();
+    }
+
+    public function setModel($model_namespace)
+    {
+        parent::setModel($model_namespace); // TODO: Change the autogenerated stub
     }
 
     public function getValue($key, $default = null)
index 43dba8b740e5a13d5274891614ff8567777dd407..e130f38be278e73edb028d8359ff52016719b7b2 100644 (file)
@@ -182,6 +182,7 @@ class CubistMagicController extends CubistCrudController
         if (is_array($field)) {
             $field = Field::getInstance($field);
         }
+        $field->setCrud($this->crud);
         if (!$field->getAttribute('fillable', true)) {
             $field->setAttribute('type', 'hidden');
         }
index 8bae1708932fc4388c77e50678aea015c9174967..9c5bfd79fa998d37d5e5a5a02336f2b490d94b9a 100644 (file)
@@ -21,6 +21,9 @@ class Field implements \ArrayAccess
 
     protected $_isRelationship = false;
 
+    /** @var CubistCrudPanel */
+    protected $_crud;
+
     protected $_columnType = 'text';
     protected $_columnMoveAfter = false;
     protected $_columnFormat = null;
@@ -95,9 +98,9 @@ class Field implements \ArrayAccess
     }
 
     /**
-     * @return CubistMagicAbstractModel
+     * @return CubistMagicAbstractModel|null
      */
-    public function getModelInstance(): CubistMagicAbstractModel
+    public function getModelInstance(): CubistMagicAbstractModel|null
     {
         return $this->_modelInstance;
     }
@@ -112,7 +115,6 @@ class Field implements \ArrayAccess
         return $this;
     }
 
-
     public function getDatabaseType()
     {
         if ($this->getAttribute('translatable')) {
@@ -523,4 +525,31 @@ class Field implements \ArrayAccess
         }
         return self::$_cachedCan[$permission];
     }
+
+    /**
+     * @return CubistCrudPanel
+     */
+    public function getCrud(): CubistCrudPanel|null
+    {
+        return $this->_crud;
+    }
+
+    /**
+     * @param CubistCrudPanel $crud
+     */
+    public function setCrud(CubistCrudPanel $crud): void
+    {
+        $this->_crud = $crud;
+        $this->_postSetCrud();
+    }
+
+    public function issetCrud()
+    {
+        return null !== $this->getCrud();
+    }
+
+    protected function _postSetCrud()
+    {
+
+    }
 }
index c9a5fc244cdd53b6338f40d67a9249218e08010f..d99f613f0d5b3b4a7e2a943f114854c18d9d0e37 100644 (file)
@@ -390,7 +390,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
 
         $this->checkForReservedNames($name);
 
-        $field = $this->bunchAddField($attributes);
+        $field = $this->bunchAddField($attributes);;
         $field->setModelInstance($this);
         $name = $field->getAttribute('name');