From 0a1fa395e00ed610287f5e94396dedc7dde3b071 Mon Sep 17 00:00:00 2001 From: jqh <841324345@qq.com> Date: Wed, 21 Oct 2020 11:12:59 +0800 Subject: [PATCH] fix #603 --- resources/views/filter/multipleselect.blade.php | 4 ++-- src/Grid/Filter/AbstractFilter.php | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/resources/views/filter/multipleselect.blade.php b/resources/views/filter/multipleselect.blade.php index 05ded0591..ba87658ed 100755 --- a/resources/views/filter/multipleselect.blade.php +++ b/resources/views/filter/multipleselect.blade.php @@ -3,9 +3,9 @@ {!! $label !!} - @foreach($options as $select => $option) - + @endforeach \ No newline at end of file diff --git a/src/Grid/Filter/AbstractFilter.php b/src/Grid/Filter/AbstractFilter.php index b258b4bcd..ac4b92240 100755 --- a/src/Grid/Filter/AbstractFilter.php +++ b/src/Grid/Filter/AbstractFilter.php @@ -592,19 +592,26 @@ protected function variables() { $variables = $this->presenter()->variables(); - $value = $this->value ?: Arr::get($this->parent->inputs(), $this->column); - return array_merge([ 'id' => $this->id, 'name' => $this->formatName($this->column), 'label' => $this->label, - 'value' => $value ?: $this->defaultValue, + 'value' => $this->normalizeValue(), 'presenter' => $this->presenter(), 'width' => $this->width, 'style' => $this->style, ], $variables); } + protected function normalizeValue() + { + if ($this->value === '' || $this->value === null) { + $this->value = Arr::get($this->parent->inputs(), $this->column); + } + + return $this->value === '' || $this->value === null ? $this->defaultValue : $this->value; + } + /** * Render this filter. *