select-bs.blade.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. {{-- Add plugin initialization and configuration code --}}
  13. @push('js')
  14. <script>
  15. $(() => {
  16. $('#{{ $id }}').selectpicker( @json($config) );
  17. // Add support to auto select old submitted values in case of
  18. // validation errors.
  19. @if($errors->any() && $enableOldSupport)
  20. let oldOptions = @json(collect($getOldValue($errorKey)));
  21. $('#{{ $id }}').selectpicker('val', oldOptions);
  22. @endif
  23. })
  24. </script>
  25. @endpush
  26. {{-- Set of CSS workarounds for the plugin --}}
  27. {{-- NOTE: this may change with newer plugin versions --}}
  28. @once
  29. @push('css')
  30. <style type="text/css">
  31. {{-- Fix the invalid visual style --}}
  32. .bootstrap-select.is-invalid {
  33. padding-right: 0px !important;
  34. }
  35. </style>
  36. @endpush
  37. @endonce