checkbox.blade.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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($loads))
  22. <script once>
  23. var selector = '{!! $selector !!}',
  24. fields = '{!! $loads['fields'] !!}'.split('^'),
  25. urls = '{!! $loads['urls'] !!}'.split('^');
  26. $(document).off('change', selector);
  27. $(document).on('change', selector, function () {
  28. var values = [];
  29. $(selector+':checked').each(function () {
  30. if (String(this.value) === '0' || this.value) {
  31. values.push(this.value)
  32. }
  33. });
  34. Dcat.helpers.loadFields(this, {
  35. group: '.fields-group',
  36. urls: urls,
  37. fields: fields,
  38. textField: "{{ $loads['textField'] }}",
  39. idField: "{{ $loads['idField'] }}",
  40. values: values,
  41. });
  42. });
  43. $(selector+':checked').trigger('change')
  44. </script>
  45. @endif