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 22
33All notable changes to ` laravel-form-components ` will be documented in this file
44
5+ ## 2.1.0 - 2020-09-14
6+
7+ - Select elements now support a slot
8+
59## 2.0.0 - 2020-09-09
610
711- Added sensible 'for' attributes to the Bootstrap 4 Label components.
Original file line number Diff line number Diff line change 1717 @endif
1818
1919 {!! $attributes -> merge ([' class' => ' form-control ' . ($hasError ($name ) ? ' is-invalid' : ' ' )]) ! !} >
20- @foreach ($options as $key => $option )
20+ @forelse ($options as $key => $option )
2121 <option value =" {{ $key } }" @if ($isSelected ($key ) ) selected =" selected" @endif >
2222 {{ $option } }
2323 </option >
24- @endforeach
24+ @empty
25+ {!! $slot ! !}
26+ @endforelse
2527 </select >
2628
2729 {!! $help ?? null ! !}
Original file line number Diff line number Diff line change 1616 {!! $attributes -> merge ([
1717 ' class' => ($label ? ' mt-1' : ' ' ) . ' block w-full ' . ($multiple ? ' form-multiselect' : ' form-select' )
1818 ]) ! !} >
19- @foreach ($options as $key => $option )
19+ @forelse ($options as $key => $option )
2020 <option value =" {{ $key } }" @if ($isSelected ($key ) ) selected =" selected" @endif >
2121 {{ $option } }
2222 </option >
23- @endforeach
23+ @empty
24+ {!! $slot ! !}
25+ @endforelse
2426 </select >
2527 </label >
2628
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