2024-07-22 13:09:45 +00:00
|
|
|
<x-leenooks::form.base {{ $attributes }}>
|
2024-07-23 23:09:49 +00:00
|
|
|
<input type="hidden" id="{{ $name }}_disabled" name="{{ $name }}" value="" disabled>
|
2024-07-25 03:52:29 +00:00
|
|
|
<select class="form-control @error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @required(isset($required)) @disabled(isset($disabled))>
|
2024-08-10 12:25:03 +00:00
|
|
|
@if(! empty($value) || isset($addnew) || isset($choose))
|
|
|
|
<option value=""></option>
|
|
|
|
@isset($addnew)
|
|
|
|
<option value="new">{{ $addnew ?: 'Add New' }}</option>
|
|
|
|
@endisset
|
2024-07-22 13:09:45 +00:00
|
|
|
@endif
|
|
|
|
|
2024-08-14 12:19:53 +00:00
|
|
|
@isset($options)
|
|
|
|
@empty($groupby)
|
|
|
|
@foreach($options as $option)
|
|
|
|
@continue(! Arr::get($option,'value'))
|
|
|
|
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
|
|
|
|
@endforeach
|
2024-08-10 12:25:03 +00:00
|
|
|
|
2024-08-14 12:19:53 +00:00
|
|
|
@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)
|
|
|
|
@continue(! Arr::get($option,'value'))
|
|
|
|
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
|
|
|
|
@endforeach
|
|
|
|
</optgroup>
|
|
|
|
@endforeach
|
|
|
|
@endempty
|
|
|
|
@endisset
|
2024-07-22 13:09:45 +00:00
|
|
|
</select>
|
|
|
|
</x-leenooks::form.base>
|
|
|
|
|
2024-08-10 12:25:03 +00:00
|
|
|
@pa(select2)
|
2024-07-22 13:09:45 +00:00
|
|
|
|
2024-08-10 12:25:03 +00:00
|
|
|
@section('page-scripts')
|
2024-07-22 13:09:45 +00:00
|
|
|
<script type="text/javascript">
|
2024-07-23 23:09:49 +00:00
|
|
|
// Select doesnt support read only so we'll use disable and a new field
|
2024-07-25 03:52:29 +00:00
|
|
|
function {{$id ?? $name}}_readonly(on) {
|
2024-07-23 23:09:49 +00:00
|
|
|
if (on) {
|
|
|
|
$('#{{ $name }}').prop('disabled',true);
|
|
|
|
$('#{{ $name }}_disabled').prop('disabled',false).val($('#{{ $name }}').val());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$('#{{ $name }}').prop('disabled',false);
|
|
|
|
$('#{{ $name }}_disabled').prop('disabled',true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-22 13:09:45 +00:00
|
|
|
$(document).ready(function() {
|
2024-07-25 03:52:29 +00:00
|
|
|
$('#{{ $id ?? $name }}').select2({
|
2024-07-22 13:09:45 +00:00
|
|
|
dropdownAutoWidth: true,
|
|
|
|
width: 'style',
|
|
|
|
@isset($addvalues)
|
|
|
|
tags: true,
|
|
|
|
placeholder: '',
|
|
|
|
allowClear: true,
|
|
|
|
@endisset
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
@append
|