leenooks/resources/themes/adminlte/views/widget/form_select.blade.php

57 lines
1.7 KiB
PHP
Raw Normal View History

<div class="form-group">
<label for="{{ $id }}">{{ $label }}</label>
<div class="input-group has-validation">
@empty($icon)
@else
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa-fw {{ $icon }}"></i></span>
</div>
@endempty()
<select class="form-control @error($id) is-invalid @enderror" id="{{ $id }}" name="{{ $name ?? $id}}">
@if(! isset($addvalues) || ! $addvalues)
<option id="new"></option>
@endif
@empty($groupby)
@foreach($options as $option)
@empty(Arr::get($option,'value')) @continue @endempty
<option value="{{ Arr::get($option,'id') }}" @if(Arr::get($option,'id') == old($old,$value))selected @endif>{{ Arr::get($option,'value') }}</option>
@endforeach
@else
@foreach($options->groupBy($groupby) as $group)
<optgroup label="{{ $groupby == 'active' ? (Arr::get($group->first(),$groupby) ? 'Active' : 'Not Active') : Arr::get($group->first(),$groupby) }}">
@foreach($group as $option)
@empty(Arr::get($option,'value')) @continue @endempty
<option value="{{ Arr::get($option,'id') }}" @if(Arr::get($option,'id') == old($old,$value))selected @endif>{{ Arr::get($option,'value') }}</option>
@endforeach
</optgroup>
@endforeach
@endempty
</select>
<span class="invalid-feedback" role="alert">
@error($id)
{{ $message }}
@enderror
</span>
</div>
</div>
@section('page-scripts')
@css(select2)
@js(select2,autofocus)
<script type="text/javascript">
$(document).ready(function() {
$('#{{ $id }}').select2({
dropdownAutoWidth: true,
width: 'style',
@isset($addvalues)
tags: true,
placeholder: '',
allowClear: true,
@endisset
});
});
</script>
@append