ldc-gen-game-web/resources/views/partials/inputs/tinyint-enum.blade.php

49 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2023-12-06 16:39:21 +01:00
{{-- 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
--}}
2023-08-21 10:22:07 +02:00
@if(!empty($label))
<label for="{{ $name }}" class="col-form-label"><b>{{ $label }}@if(!empty($required)) * @endif</b></label>
@endif
<select
id="{{ $name }}"
2023-12-06 16:39:21 +01:00
@class([
'form-select',
'is-invalid' => $errors->has($name)
])
name="{{ $name }}"
aria-describedby="{{ $id }}Help"
@if(!empty($disabled))
disabled
@endif
@if(!empty($required))
required
@endif
role="button">
2023-08-21 10:22:07 +02:00
@foreach ($associatedModels as $associatedModel)
<option
value="{{ $associatedModel->value}}"
@if (old($name, $model->{$name}->value ?? $value ?? 1) == $associatedModel->value)
selected
@endif>
2023-08-21 10:22:07 +02:00
{{ $associatedModel->label }}
</option>
@endforeach
</select>
@include('modules.input-error', [
'inputName' => $name,
2023-12-06 16:39:21 +01:00
'helperId' => "{$id}Help",
2023-08-21 10:22:07 +02:00
'helper' => $helper
])