TIF_Nganjuk_E41220879/resources/views/components/form-select.blade.php

35 lines
1.2 KiB
PHP

@props(['label' => '', 'name', 'options' => [], 'value' => '', 'placeholder' => 'Pilih...', 'required' => false, 'error' => null])
<div class="mb-4">
@if($label)
<label for="{{ $name }}" class="block text-sm font-medium text-[#2F347A] mb-1">
{{ $label }}
@if($required)
<span class="text-red-500">*</span>
@endif
</label>
@endif
<select
name="{{ $name }}"
id="{{ $name }}"
{{ $required ? 'required' : '' }}
{{ $attributes->merge(['class' => 'w-full px-4 py-2.5 border border-[#E5E7F2] rounded-lg focus:ring-2 focus:ring-[#4A538F] focus:border-[#4A538F] transition-colors bg-white text-[#2F347A] ' . ($error ? 'border-red-500' : '')]) }}
>
@if(count($options) > 0)
<option value="">{{ $placeholder }}</option>
@foreach($options as $key => $optionLabel)
<option value="{{ $key }}" {{ old($name, $value) == $key ? 'selected' : '' }}>
{{ $optionLabel }}
</option>
@endforeach
@else
{{ $slot }}
@endif
</select>
@if($error)
<p class="mt-1 text-sm text-red-600">{{ $error }}</p>
@endif
</div>