]> _ Git - cubist_cms-back.git/commitdiff
wait #6427 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Oct 2023 07:00:03 +0000 (09:00 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 19 Oct 2023 07:00:03 +0000 (09:00 +0200)
src/app/Magic/Fields/SelectFromArray.php
src/resources/views/fields/select2_from_array.blade.php

index 763a9a2845df0084473779a577169bb33f18f974..b307d6db2d9f220d5f5992dd467a47b3b3029632 100644 (file)
@@ -28,6 +28,8 @@ class SelectFromArray extends Field
 
     protected $_showSeletedOption = false;
 
+    protected $_free = false;
+
     public function getDefaultAttributes()
     {
         return array_merge(parent::getDefaultAttributes(), [
@@ -38,7 +40,8 @@ class SelectFromArray extends Field
             'allows_multiple' => $this->_multiple,
             'ajax' => $this->_ajax,
             'allows_html' => $this->_allowsHTML,
-            'show_selected_option' => $this->_showSeletedOption
+            'show_selected_option' => $this->_showSeletedOption,
+            'free' => $this->_free,
         ]);
     }
 
index d6aba02dbc25ffac951e928a864e85b80d513be8..c0e97f556a789fda1f975abe99130c38d0f68242 100644 (file)
@@ -39,6 +39,7 @@ if($ajax){
     @if($ajax) data-ajax="{{$field['ajax']}}" @endif
     @if($allows_html) data-allow-html="1" @endif
     data-options="{{ json_encode($field['options']) }}"
+    @if($field['free']) data-free="1" @endif
     data-value="{{is_scalar($o)?$o:json_encode($o)}}"
 >
     @if (isset($field['allows_null']) && $field['allows_null']==true)
@@ -130,6 +131,7 @@ if($ajax){
                     var options = {
                         theme: "bootstrap",
                     };
+                    options.tags = $(this).is('[data-free]');
                     if ($(this).is('[data-ajax]')) {
                         options.ajax = {
                             url: '{{backpack_url('select2')}}' + '/' + $(this).data('ajax'),