From: Vincent Vanwaelscappel Date: Thu, 4 Jan 2024 19:17:15 +0000 (+0100) Subject: wip #6571 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b98bb7eeffa12604100d96728982882d1e465069;p=cubist_cms-back.git wip #6571 @2 --- diff --git a/src/app/CubistCrudPanel.php b/src/app/CubistCrudPanel.php index 86439dc..9b99c56 100644 --- a/src/app/CubistCrudPanel.php +++ b/src/app/CubistCrudPanel.php @@ -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) diff --git a/src/app/Magic/Controllers/CubistMagicController.php b/src/app/Magic/Controllers/CubistMagicController.php index 43dba8b..e130f38 100644 --- a/src/app/Magic/Controllers/CubistMagicController.php +++ b/src/app/Magic/Controllers/CubistMagicController.php @@ -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'); } diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index 8bae170..9c5bfd7 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -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() + { + + } } diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index c9a5fc2..d99f613 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -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');