From: Vincent Vanwaelscappel Date: Mon, 28 Feb 2022 16:50:02 +0000 (+0100) Subject: wait #5131 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=084d5a438ce9282f6ca53a2a6682575c62642651;p=cubist_cms-back.git wait #5131 @0.5 --- diff --git a/src/app/Magic/Fields/SelectFromArray.php b/src/app/Magic/Fields/SelectFromArray.php index 246e6a4..8c28c88 100644 --- a/src/app/Magic/Fields/SelectFromArray.php +++ b/src/app/Magic/Fields/SelectFromArray.php @@ -34,9 +34,6 @@ class SelectFromArray extends Field if ($this->getAttribute('default') !== null && $this->getAttribute('allows_null')) { $this->setAttribute('allows_null', false); } - if ($this->getAttribute('ajax', false)) { - $this->setAttribute('ajax', self::hashOptions($this->getOptions())); - } } public static function hashOptions($options) diff --git a/src/app/Magic/Fields/SelectFromModel.php b/src/app/Magic/Fields/SelectFromModel.php index 4eb0543..f6ea42d 100644 --- a/src/app/Magic/Fields/SelectFromModel.php +++ b/src/app/Magic/Fields/SelectFromModel.php @@ -51,10 +51,6 @@ class SelectFromModel extends Model parent::_preGetDefinition(); $o=$this->_getOptions(); $this->setAttribute('options', $o); - if ($this->getAttribute('ajax', false)) { - $this->setAttribute('ajax', SelectFromArray::hashOptions($o)); - } - } public function _postSetAttributes() diff --git a/src/resources/views/fields/select2_from_array.blade.php b/src/resources/views/fields/select2_from_array.blade.php index 9f1a74c..bd15618 100644 --- a/src/resources/views/fields/select2_from_array.blade.php +++ b/src/resources/views/fields/select2_from_array.blade.php @@ -18,6 +18,10 @@ } $ajax=isset($field['ajax']) && $field['ajax']; + +if($ajax){ + $field['ajax']=\Cubist\Backpack\Magic\Fields\SelectFromArray::hashOptions($field['options']); +} @endphp