{{-- checklist --}} @php $key_attribute = (new $field['model'])->getKeyName(); $field['attribute'] = $field['attribute'] ?? (new $field['model'])->identifiableAttribute(); $field['number_of_columns'] = $field['number_of_columns'] ?? 3; // calculate the checklist options if (!isset($field['options'])) { $field['options'] = $field['model']::all()->pluck($field['attribute'], $key_attribute)->toArray(); } else { $field['options'] = call_user_func($field['options'], $field['model']::query()); } // calculate the value of the hidden input $field['value'] = old_empty_or_null($field['name'], []) ?? $field['value'] ?? $field['default'] ?? []; if(!empty($field['value'])) { if (is_a($field['value'], \Illuminate\Support\Collection::class)) { $field['value'] = ($field['value'])->pluck($key_attribute)->toArray(); } elseif (is_string($field['value'])){ $field['value'] = json_decode($field['value']); } } // define the init-function on the wrapper $field['wrapper']['data-init-function'] = $field['wrapper']['data-init-function'] ?? 'bpFieldInitChecklist'; @endphp @include('crud::fields.inc.wrapper_start') @include('crud::fields.inc.translatable_icon')
@foreach ($field['options'] as $key => $option)
@endforeach
{{-- HINT --}} @if (isset($field['hint']))

{!! $field['hint'] !!}

@endif @include('crud::fields.inc.wrapper_end') {{-- ########################################## --}} {{-- Extra CSS and JS for this particular field --}} {{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}} {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') @bassetBlock('backpack/crud/fields/checklist-field.js') @endBassetBlock @endpush {{-- End of Extra CSS and JS --}} {{-- ########################################## --}}