ldc-legaulois/resources/views/bo/partials/inputs/tinyint-enum.blade.php
2024-03-28 13:10:53 +01:00

42 lines
1.8 KiB
PHP

{{-- blade-formatter-disable --}}
{{--
VARIABLE || COMMENT || TYPE || REQUIRED || DEFAULT
$id || The id of the select tag. || string || REQUIRED ||
$name || The name of the select tag. || string || REQUIRED ||
$helper || The helper of the input. || string || REQUIRED ||
$associatedModels || The enum to associate. || Enum || REQUIRED ||
$label || The text displayed as a label. || string || OPTIONNAL || null
$disabled || Is the field disabled ? || boolean || OPTIONNAL || false
$required || Is the field required ? || boolean || OPTIONNAL || false
$value || The default selected option. || integer || OPTIONNAL || 1
$model || The model we're creating/editing || Model class || OPTIONNAL || null
--}}
@if(!empty($label))
<label for="{{ $name }}" class="col-form-label"><b>{{ $label }}@if(!empty($required)) * @endif</b></label>
@endif
<select
id="{{ $name }}"
@class([
'form-select',
'is-invalid' => $errors->has($name)
])
name="{{ $name }}"
aria-describedby="{{ $id }}Help"
@disabled(!empty($disabled))
@required(!empty($required))
role="button">
@foreach ($associatedModels as $associatedModel)
<option
value="{{ $associatedModel->value}}"
@selected(old($name, $model->{$name}->value ?? $value ?? 1) == $associatedModel->value)>
{{ $associatedModel->label }}
</option>
@endforeach
</select>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{$id}Help",
'helper' => $helper
])