]> _ Git - cubist_cms-back.git/commitdiff
wait #5131 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Feb 2022 16:50:02 +0000 (17:50 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 28 Feb 2022 16:50:02 +0000 (17:50 +0100)
src/app/Magic/Fields/SelectFromArray.php
src/app/Magic/Fields/SelectFromModel.php
src/resources/views/fields/select2_from_array.blade.php

index 246e6a4e4c86a61db25534d9ecf431cb3123e602..8c28c886212dc2b940e0a11fedda246cbfdaacc9 100644 (file)
@@ -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)
index 4eb054392b35aacb13ab7778cfc6c74df655ce46..f6ea42d6f14c9feb1112ba5e3fd63ec262f07b20 100644 (file)
@@ -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()
index 9f1a74cc6d4596c4a38c5a5e5dd9521b0ee3ed21..bd15618c023b09c79bdaf6ab7a4f5a4d0dd45935 100644 (file)
     }
 
     $ajax=isset($field['ajax']) && $field['ajax'];
+
+if($ajax){
+    $field['ajax']=\Cubist\Backpack\Magic\Fields\SelectFromArray::hashOptions($field['options']);
+}
 @endphp
 
 <!-- select2 from array -->