From 9658b8f8049b120ae3e87a7fda346e1093f82657 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Mon, 17 Jun 2019 14:51:12 +0200 Subject: [PATCH] done #2840 @0:10 --- src/app/Magic/Fields/Model.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/Magic/Fields/Model.php b/src/app/Magic/Fields/Model.php index 2b231b4..0bba065 100644 --- a/src/app/Magic/Fields/Model.php +++ b/src/app/Magic/Fields/Model.php @@ -6,6 +6,8 @@ namespace Cubist\Backpack\app\Magic\Fields; class Model extends Field { + protected static $_options = null; + public function getColumnData() { $res = parent::getColumnData(); @@ -14,17 +16,20 @@ class Model extends Field return $res; } - protected function _postSetAttributes() - { - parent::_postSetAttributes(); - } - public function getDefaultAttributes() { return array_merge(parent::getDefaultAttributes(), ['attribute' => 'name', 'allows_null' => false, 'allows_multiple' => $this->_multiple]); } protected function _getOptions() + { + if (null === static::$_options) { + static::$_options = $this->__getOptions(); + } + return static::$_options; + } + + protected function __getOptions() { $modelClass = $this->getAttribute('optionsmodel'); $inst = new $modelClass(); -- 2.39.5