From: Vincent Vanwaelscappel Date: Thu, 10 Dec 2020 19:36:18 +0000 (+0100) Subject: wip #3753 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8633da03b24ab3a0f96ade411e11a434cfba4e10;p=cubist_cms-back.git wip #3753 @0.5 --- diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index ac77922..4e3c54d 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -43,6 +43,7 @@ class Field implements \ArrayAccess protected $_migrateTranslatable = false; protected $_can = null; + protected $_canWrite = null; protected $_auth = true; /** @@ -119,7 +120,7 @@ class Field implements \ArrayAccess 'preview' => $this->_preview, 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic, 'allow_null' => true, - 'can' => $this->_can, 'auth' => $this->_auth, + 'can' => $this->_can, 'can_write' => $this->_canWrite, 'auth' => $this->_auth, 'database_unique' => $this->_databaseUnique, 'database_index' => $this->_databaseIndex, 'fake' => false, 'store_in' => 'extras', 'attributes' => []]; } @@ -301,6 +302,13 @@ class Field implements \ArrayAccess $this->setAttribute('view_namespace', CubistBackpackServiceProvider::NAMESPACE . '::fields'); } } + + if (null !== $this->getAttribute('can_write', null)) { + if (!can($this->getAttribute('can_write'))) { + $this->setAttribute('type', 'static'); + $this->setAttribute('view_namespace', CubistBackpackServiceProvider::NAMESPACE . '::fields'); + } + } } /**