From 0d58e9471fd33aa0392543143deaa663c3cb2da2 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 28 Dec 2023 15:14:34 +0100 Subject: [PATCH] wait #6601 @0.5 --- .../Controllers/CubistMagicController.php | 4 +-- src/app/Magic/Fields/SelectFromArray.php | 3 +++ .../views/fields/select2_from_array.blade.php | 27 ++++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/app/Magic/Controllers/CubistMagicController.php b/src/app/Magic/Controllers/CubistMagicController.php index d6f9776..43dba8b 100644 --- a/src/app/Magic/Controllers/CubistMagicController.php +++ b/src/app/Magic/Controllers/CubistMagicController.php @@ -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) { diff --git a/src/app/Magic/Fields/SelectFromArray.php b/src/app/Magic/Fields/SelectFromArray.php index b307d6d..887986b 100644 --- a/src/app/Magic/Fields/SelectFromArray.php +++ b/src/app/Magic/Fields/SelectFromArray.php @@ -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)]; } diff --git a/src/resources/views/fields/select2_from_array.blade.php b/src/resources/views/fields/select2_from_array.blade.php index 216197b..55044bc 100644 --- a/src/resources/views/fields/select2_from_array.blade.php +++ b/src/resources/views/fields/select2_from_array.blade.php @@ -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 - + @include('crud::fields.inc.wrapper_start') @if (isset($field['allows_multiple']) && $field['allows_multiple']==true) @endif