From 972df339f5243c5986c32d2a550fbb2191530ffe Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 13 Aug 2019 17:45:48 +0200 Subject: [PATCH] fix #2870 @1.5 --- .../views/fields/select2_from_array.blade.php | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/resources/views/fields/select2_from_array.blade.php b/src/resources/views/fields/select2_from_array.blade.php index 4e65f41..c9a64aa 100644 --- a/src/resources/views/fields/select2_from_array.blade.php +++ b/src/resources/views/fields/select2_from_array.blade.php @@ -1,3 +1,7 @@ +@php + $is_null=null===old(square_brackets_to_dots($field['name'])) && null===$field['value']; +@endphp +
@@ -9,18 +13,24 @@ > @if (isset($field['allows_null']) && $field['allows_null']==true) - + @if($is_null) + + @else + + @endif @endif @if (count($field['options'])) @foreach ($field['options'] as $key => $value) - @if((old(square_brackets_to_dots($field['name'])) && ( + @if( + !$is_null && ( + (old(square_brackets_to_dots($field['name'])) && ( $key == old(square_brackets_to_dots($field['name'])) || (is_array(old(square_brackets_to_dots($field['name']))) && in_array($key, old(square_brackets_to_dots($field['name'])))))) || (null === old(square_brackets_to_dots($field['name'])) && ((isset($field['value']) && ( - $key == $field['value'] || ( + ($key == $field['value'] && null !== $field['value'] )|| ( is_array($field['value']) && in_array($key, $field['value']) ) @@ -32,7 +42,7 @@ ) ) )) - )) + ))) @else @@ -75,7 +85,7 @@ function initUntriggeredSelectFromArray() { // trigger select2 for each untriggered select2 box $('.select2_from_array').each(function (i, obj) { - if($(obj).closest('.item.sample').length>0){ + if ($(obj).closest('.item.sample').length > 0) { return; } -- 2.39.5