From: Vincent Vanwaelscappel Date: Thu, 19 Oct 2023 07:00:03 +0000 (+0200) Subject: wait #6427 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3fbc2c99470a62cf47f760538c36cfd3578daa6e;p=cubist_cms-back.git wait #6427 @0.5 --- diff --git a/src/app/Magic/Fields/SelectFromArray.php b/src/app/Magic/Fields/SelectFromArray.php index 763a9a2..b307d6d 100644 --- a/src/app/Magic/Fields/SelectFromArray.php +++ b/src/app/Magic/Fields/SelectFromArray.php @@ -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, ]); } diff --git a/src/resources/views/fields/select2_from_array.blade.php b/src/resources/views/fields/select2_from_array.blade.php index d6aba02..c0e97f5 100644 --- a/src/resources/views/fields/select2_from_array.blade.php +++ b/src/resources/views/fields/select2_from_array.blade.php @@ -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'),