]> _ Git - cubist_cms-back.git/commitdiff
wait #6601 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 28 Dec 2023 14:14:34 +0000 (15:14 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 28 Dec 2023 14:14:34 +0000 (15:14 +0100)
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Fields/SelectFromArray.php
src/resources/views/fields/select2_from_array.blade.php

index d6f97769d23f30987ff6808cd62f93a9b5a91453..43dba8b740e5a13d5274891614ff8567777dd407 100644 (file)
@@ -108,7 +108,6 @@ class CubistMagicController extends CubistCrudController
 
     public function setupSaveActions($type)
     {
-
         $instance = $this->getModelInstance();
         if ($instance instanceof CubistMagicAbstractModel) {
             if ($this->_oneInstance) {
@@ -116,7 +115,7 @@ class CubistMagicController extends CubistCrudController
                 $this->crud->removeSaveAction('save_and_new');
                 $this->crud->removeSaveAction('save_and_edit');
                 $this->crud->addSaveAction([
-                    'name' => 'save_and_edit',
+                    'name' => 'save_and_back',
                     'visible' => function ($crud) {
                         return $crud->hasAccess('update');
                     },
@@ -129,7 +128,6 @@ class CubistMagicController extends CubistCrudController
                         if ($request->has('current_tab')) {
                             $redirectUrl = $redirectUrl . '#' . $request->get('current_tab');
                         }
-
                         return $redirectUrl;
                     },
                     'referrer_url' => function ($crud, $request, $itemId) {
index b307d6db2d9f220d5f5992dd467a47b3b3029632..887986bd5d828274bddbae2a0411a6c7c15a31d2 100644 (file)
@@ -56,6 +56,9 @@ class SelectFromArray extends Field
     public static function hashOptions($options, $hash = null)
     {
         $data = [];
+        if (!is_array($options)) {
+            $options = [];
+        }
         foreach ($options as $k => $v) {
             $data[$k] = ['t' => $v, 'n' => self::normalize($v)];
         }
index 216197b3f516cfd2a12e229428a729e0fda4dc06..55044bc2cf849ae84e87ca2c636dc398b65f3a84 100644 (file)
@@ -1,5 +1,8 @@
 @php
     $o=$field['value'] ?? old(square_brackets_to_dots($field['name']))??$field['default'];
+    if(!is_array($field['options'])){
+        $field['options']=[];
+    }
 
     $is_null=null===$o || $o==='null';
     if(!function_exists('select2_from_array_selected')){
@@ -25,22 +28,22 @@ if($ajax){
 }
 @endphp
 
-    <!-- select2 from array -->
+        <!-- select2 from array -->
 @include('crud::fields.inc.wrapper_start')
 <label>{!! $field['label'] !!}</label>
 @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)
     <input type="hidden" name="{{ $field['name'] }}" value=""/>
 @endif
 <select
-    name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
-    style="width: 100%"
-    @include('crud::fields.inc.attributes', ['default_class' =>  'form-control select2_from_array'])
-    @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
-    @if($ajax) data-ajax="{{$field['ajax']}}" @endif
-    @if($allows_html) data-allow-html="1" @endif
-    data-options="{{ json_encode($field['options']) }}"
-    @if(isset($field['free']) && $field['free']) data-free="1" @endif
-    data-value="{{is_scalar($o)?$o:json_encode($o)}}"
+        name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
+        style="width: 100%"
+        @include('crud::fields.inc.attributes', ['default_class' =>  'form-control select2_from_array'])
+        @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
+        @if($ajax) data-ajax="{{$field['ajax']}}" @endif
+        @if($allows_html) data-allow-html="1" @endif
+        data-options="{{ json_encode($field['options']) }}"
+        @if(isset($field['free']) && $field['free']) data-free="1" @endif
+        data-value="{{is_scalar($o)?$o:json_encode($o)}}"
 >
     @if (isset($field['allows_null']) && $field['allows_null']==true)
         @if($is_null)
@@ -95,8 +98,8 @@ if($ajax){
         <link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet"
               type="text/css"/>
         <link
-            href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
-            rel="stylesheet" type="text/css"/>
+                href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
+                rel="stylesheet" type="text/css"/>
     @endpush
 
     {{-- FIELD JS - will be loaded in the after_scripts section --}}