select.blade.php 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. @extends('adminlte::components.form.input-group-component')
  2. {{-- Set errors bag internallly --}}
  3. @php($setErrorsBag($errors ?? null))
  4. {{-- Set input group item section --}}
  5. @section('input_group_item')
  6. {{-- Select --}}
  7. <select id="{{ $id }}" name="{{ $name }}"
  8. {{ $attributes->merge(['class' => $makeItemClass()]) }}>
  9. {{ $slot }}
  10. </select>
  11. @overwrite
  12. {{-- Support to auto select the old submitted values --}}
  13. @if($errors->any() && $enableOldSupport)
  14. @push('js')
  15. <script>
  16. $(() => {
  17. let oldOptions = @json(collect($getOldValue($errorKey)));
  18. $('#{{ $id }} option').each(function()
  19. {
  20. let value = $(this).val() || $(this).text();
  21. $(this).prop('selected', oldOptions.includes(value));
  22. });
  23. });
  24. </script>
  25. @endpush
  26. @endif