Skip to content

Commit b47dc66

Browse files
committed
⚗️ Change wire:model strategy for checkboxes
Signed-off-by: Julio Renzi C. Motol <[email protected]>
1 parent 6616cdc commit b47dc66

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

resources/views/bootstrap-4/includes/filter-type-multiselect.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@foreach($filter->options() as $optionKey => $value)
2-
<div class="form-check">
2+
<div class="form-check" wire:key="filter-{{ $key }}-multiselect-{{ $optionKey }}">
33
<input
44
class="form-check-input"
55
onclick="event.stopPropagation();"
66
type="checkbox"
77
id="filter-{{$key}}-{{ $loop->index }}"
8-
wire:model="filters.{{$key}}.{{ $loop->index }}"
8+
wire:model="filters.{{$key}}"
99
value="{{ $optionKey }}"
1010
>
1111
<label class="form-check-label" for="filter-{{$key}}-{{ $loop->index }}">{{ $value }}</label>

resources/views/bootstrap-5/includes/filter-type-multiselect.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@foreach($filter->options() as $optionKey => $value)
2-
<div class="form-check">
2+
<div class="form-check" wire:key="filter-{{ $key }}-multiselect-{{ $optionKey }}">
33
<input
44
onclick="event.stopPropagation();"
55
type="checkbox"
66
id="filter-{{$key}}-{{ $loop->index }}"
7-
wire:model="filters.{{$key}}.{{ $loop->index }}"
7+
wire:model="filters.{{$key}}"
88
value="{{ $optionKey }}"
99
>
1010
<label class="form-check-label" for="filter-{{$key}}-{{ $loop->index }}">{{ $value }}</label>
Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
<div class="mt-1 relative rounded-md">
2-
{{-- We're not using a select element, but for UX, we choose checkboxes--}}
3-
{{-- <select--}}
4-
{{-- wire:model.stop="filters.{{ $key }}"--}}
5-
{{-- wire:key="filter-{{ $key }}"--}}
6-
{{-- id="filter-{{ $key }}"--}}
7-
{{-- class="rounded-md shadow-sm block w-full pl-3 pr-10 py-2 text-base leading-6 border-gray-300 focus:outline-none focus:border-indigo-300 focus:shadow-outline-indigo sm:text-sm sm:leading-5"--}}
8-
{{-- multiple="multiple"--}}
9-
{{-- >--}}
10-
{{-- @foreach($filter->options() as $key => $value)--}}
11-
{{-- <option value="{{ $key }}">{{ $value }}</option>--}}
12-
{{-- @endforeach--}}
13-
{{-- </select>--}}
14-
152
@foreach($filter->options() as $optionKey => $value)
16-
<input
17-
type="checkbox"
18-
id="filter-{{$key}}-{{ $loop->index }}"
19-
wire:key="filter-{{$key}}-{{ $loop->index }}"
20-
wire:model.stop="filters.{{$key}}.{{ $loop->index }}"
21-
value="{{ $optionKey }}"
22-
>
23-
<label for="filter-{{$key}}-{{ $loop->index }}">{{ $value }}</label>
24-
<br>
3+
<div wire:key="filter-{{ $key }}-multiselect-{{ $optionKey }}">
4+
<input
5+
type="checkbox"
6+
id="filter-{{$key}}-{{ $loop->index }}"
7+
wire:key="filter-{{$key}}-{{ $loop->index }}"
8+
wire:model="filters.{{$key}}"
9+
value="{{ $optionKey }}"
10+
>
11+
<label for="filter-{{$key}}-{{ $loop->index }}">{{ $value }}</label>
12+
</div>
2513
@endforeach
2614
</div>

0 commit comments

Comments
 (0)