26 lines
1.2 KiB
PHP
26 lines
1.2 KiB
PHP
@props([
|
|
'name',
|
|
'label',
|
|
'options', // kolekcja: [klucz => etykieta] lub lista etykiet (gdy valueIsLabel)
|
|
'selected' => null,
|
|
'required' => false,
|
|
'placeholder' => null,
|
|
'valueIsLabel' => false, // true → value = etykieta (słowniki opisowe: WLL_SYS_TYPE itp.)
|
|
])
|
|
|
|
<div {{ $attributes->only('class')->merge(['class' => 'space-y-1']) }}>
|
|
<label for="{{ $name }}" class="font-data-label text-data-label text-on-surface-variant tracking-wide">
|
|
{{ $label }}@if ($required) <span class="text-primary">*</span>@endif
|
|
</label>
|
|
<select id="{{ $name }}" name="{{ $name }}" @required($required)
|
|
class="w-full bg-surface-container-low border border-outline-variant px-3 py-2 rounded focus:ring-1 focus:ring-primary focus:border-primary font-data-label text-on-surface transition-all">
|
|
@if ($placeholder)
|
|
<option value="">{{ $placeholder }}</option>
|
|
@endif
|
|
@foreach ($options as $key => $text)
|
|
@php($optionValue = $valueIsLabel ? $text : $key)
|
|
<option value="{{ $optionValue }}" @selected((string) old($name, $selected) === (string) $optionValue)>{{ $text }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|