Skip to content

Commit

Permalink
fix #603
Browse files Browse the repository at this point in the history
  • Loading branch information
jqhph committed Oct 21, 2020
1 parent a189627 commit 0a1fa39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions resources/views/filter/multipleselect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<span class="input-group-text bg-white text-capitalize"><b>{!! $label !!}</b></span>
</div>

<select class="form-control {{ $class }}" name="{{$name}}[]" multiple style="width: 100%;">
<select class="form-control {{ $class }}" name="{{ $name }}[]" multiple style="width: 100%;">
@foreach($options as $select => $option)
<option value="{{$select}}" {{ in_array((string)$select, request($name, [])) ?'selected':'' }}>{{$option}}</option>
<option value="{{$select}}" {{ in_array((string)$select, (array) $value) ?'selected':'' }}>{{$option}}</option>
@endforeach
</select>
</div>
13 changes: 10 additions & 3 deletions src/Grid/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 0a1fa39

Please sign in to comment.