checkbox.blade.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <div class="{{$viewClass['form-group']}}" >
  2. <label class="{{$viewClass['label']}} control-label pt-0">{!! $label !!}</label>
  3. <div class="{{$viewClass['field']}}">
  4. @if($checkAll)
  5. {!! $checkAll !!}
  6. <hr style="margin-top: 10px;margin-bottom: 0;">
  7. @endif
  8. @include('admin::form.error')
  9. {!! $checkbox !!}
  10. <input type="hidden" name="{{$name}}[]">
  11. @include('admin::form.help-block')
  12. </div>
  13. </div>
  14. @if(! empty($canCheckAll))
  15. <script init="[name='_check_all_']" once>
  16. $this.on('change', function () {
  17. $(this).parents('.form-field').find('input[type="checkbox"]:not(:first)').prop('checked', this.checked).trigger('change');
  18. });
  19. </script>
  20. @endif
  21. @if(! empty($load))
  22. <script once>
  23. var selector = '{!! $selector !!}';
  24. $(document).off('change', selector);
  25. $(document).on('change', selector, function () {
  26. var values = [];
  27. $(selector+':checked').each(function () {
  28. if (String(this.value) === '0' || this.value) {
  29. values.push(this.value)
  30. }
  31. });
  32. Dcat.helpers.loadField(this, {
  33. group: '{{ $load['group'] ?? '.fields-group' }}',
  34. class: '.{{ $load['class'] }}',
  35. url: "{!! $load['url'].(strpos($load['url'],'?')?'&':'?') !!}q=",
  36. textField: "{{ $load['textField'] }}",
  37. idField: "{{ $load['idField'] }}",
  38. values: values,
  39. });
  40. });
  41. $(selector+':checked').trigger('change')
  42. </script>
  43. @endif
  44. @if(! empty($loads))
  45. <script once>
  46. var selector = '{!! $selector !!}',
  47. fields = '{!! $loads['fields'] !!}'.split('^'),
  48. urls = '{!! $loads['urls'] !!}'.split('^');
  49. $(document).off('change', selector);
  50. $(document).on('change', selector, function () {
  51. var values = [];
  52. $(selector+':checked').each(function () {
  53. if (String(this.value) === '0' || this.value) {
  54. values.push(this.value)
  55. }
  56. });
  57. Dcat.helpers.loadFields(this, {
  58. group: '.fields-group',
  59. urls: urls,
  60. fields: fields,
  61. textField: "{{ $loads['textField'] }}",
  62. idField: "{{ $loads['idField'] }}",
  63. values: values,
  64. });
  65. });
  66. $(selector+':checked').trigger('change')
  67. </script>
  68. @endif