{{-- Form field with label and error message. type: text | email | tel | number | textarea | select (pass :options) | radio-group (pass :options) | file (pass accept=".pdf,.doc") --}} @props([ 'name', 'label', 'type' => 'text', 'required' => false, 'options' => [], 'placeholder' => '', 'hint' => null, 'autocomplete' => null, 'value' => null, // default choice for a select, used when there is no old input 'accept' => null, // file types offered by a file field's picker ]) @php $id = 'f-'.$name; $hasError = $errors->has($name); $errorClass = $hasError ? '!border-red-500' : ''; @endphp
only('class') }}> @if ($type === 'radio-group')
{{ $label }} @if ($required)@endif
@foreach ($options as $option) @endforeach
@else @if ($type === 'textarea') @elseif ($type === 'select') @elseif ($type === 'file') {{-- A file can never be refilled after a failed submit, so there is no value. --}} @else @endif @endif @if ($hint)

{{ $hint }}

@endif @error($name)

{{ $message }}

@enderror