This repository was archived by the owner on Jan 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +40
-4
lines changed Expand file tree Collapse file tree 5 files changed +40
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes to ` laravel-form-components ` will be documented in this file
4
4
5
+ ## 2.1.0 - 2020-09-14
6
+
7
+ - Select elements now support a slot
8
+
5
9
## 2.0.0 - 2020-09-09
6
10
7
11
- Added sensible 'for' attributes to the Bootstrap 4 Label components.
Original file line number Diff line number Diff line change 17
17
@endif
18
18
19
19
{!! $attributes -> merge ([' class' => ' form-control ' . ($hasError ($name ) ? ' is-invalid' : ' ' )]) ! !} >
20
- @foreach ($options as $key => $option )
20
+ @forelse ($options as $key => $option )
21
21
<option value =" {{ $key } }" @if ($isSelected ($key ) ) selected =" selected" @endif >
22
22
{{ $option } }
23
23
</option >
24
- @endforeach
24
+ @empty
25
+ {!! $slot ! !}
26
+ @endforelse
25
27
</select >
26
28
27
29
{!! $help ?? null ! !}
Original file line number Diff line number Diff line change 16
16
{!! $attributes -> merge ([
17
17
' class' => ($label ? ' mt-1' : ' ' ) . ' block w-full ' . ($multiple ? ' form-multiselect' : ' form-select' )
18
18
]) ! !} >
19
- @foreach ($options as $key => $option )
19
+ @forelse ($options as $key => $option )
20
20
<option value =" {{ $key } }" @if ($isSelected ($key ) ) selected =" selected" @endif >
21
21
{{ $option } }
22
22
</option >
23
- @endforeach
23
+ @empty
24
+ {!! $slot ! !}
25
+ @endforelse
24
26
</select >
25
27
</label >
26
28
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace ProtoneMedia \LaravelFormComponents \Tests \Feature ;
4
+
5
+ use ProtoneMedia \LaravelFormComponents \Tests \TestCase ;
6
+
7
+ class SelectSlotTest extends TestCase
8
+ {
9
+ /** @test */
10
+ public function it_shows_the_slot_if_the_options_are_empty ()
11
+ {
12
+ $ this ->registerTestRoute ('select-slot ' );
13
+
14
+ $ this ->visit ('/select-slot ' )
15
+ ->seeElement ('option[value="a"] ' )
16
+ ->seeElement ('option[value="b"] ' )
17
+ ->seeElement ('option[value="c"] ' );
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ <x-form >
2
+ <x-form-select name =" select" >
3
+ <option value =" a" >A</option >
4
+ <option value =" b" >B</option >
5
+ <option value =" c" >C</option >
6
+ </x-form-select >
7
+
8
+ <x-form-submit />
9
+ </x-form >
You can’t perform that action at this time.
0 commit comments