generated from boboko/starter
39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
{{--
|
|
<x-checkout::select name="billing_country_id" label="Country" :options="$countries" required />
|
|
|
|
`options` is an iterable of {id, name} (a Collection of models works
|
|
directly) — value/label pulled from those two keys.
|
|
--}}
|
|
@props([
|
|
'name',
|
|
'label',
|
|
'options' => [],
|
|
'value' => null,
|
|
'placeholder' => null,
|
|
'required' => false,
|
|
])
|
|
|
|
@php($selected = old($name, $value))
|
|
|
|
<div class="bbk-field">
|
|
<label class="bbk-field-label" for="bbk-{{ $name }}">{{ $label }}</label>
|
|
<select
|
|
name="{{ $name }}"
|
|
id="bbk-{{ $name }}"
|
|
@if ($required) required @endif
|
|
{{ $attributes->class(['bbk-field-input', 'bbk-field-input--error' => $errors->has($name)]) }}
|
|
>
|
|
@if ($placeholder)
|
|
<option value="" @selected(! $selected)>{{ $placeholder }}</option>
|
|
@endif
|
|
@foreach ($options as $option)
|
|
<option value="{{ $option->id }}" @selected((string) $selected === (string) $option->id)>
|
|
{{ $option->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
@error($name)
|
|
<p class="bbk-field-error">{{ $message }}</p>
|
|
@enderror
|
|
</div>
|