ldc-agis/resources/views/bo/partials/inputs/tinyint-enum.blade.php
2023-12-19 15:09:12 +00:00

44 lines
1.8 KiB
PHP

{{--
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 @if($errors->has($name)) is-invalid @endif"
name="{{ $name }}"
aria-describedby="{{ $id }}Help"
@if(!empty($disabled))
disabled
@endif
@if(!empty($required))
required
@endif
role="button">
@foreach ($associatedModels as $associatedModel)
<option
value="{{ $associatedModel->value}}"
@if (old($name, $model->{$name}->value ?? $value ?? 1) == $associatedModel->value)
selected
@endif>
{{ $associatedModel->label }}
</option>
@endforeach
</select>
@include('modules.input-error', [
'inputName' => $name,
'helperId' => "{{ $id }}Help",
'helper' => $helper
])