{{-- select2 --}} @php $current_value = old_empty_or_null($field['name'], '') ?? $field['value'] ?? $field['default'] ?? ''; //if it's part of a relationship here we have the full related model, we want the key. if (is_object($current_value) && is_subclass_of(get_class($current_value), 'Illuminate\Database\Eloquent\Model') ) { $current_value = $current_value->getKey(); } if (!isset($field['options'])) { $options = $field['model']::all(); } else { $options = call_user_func($field['options'], $field['model']::query()); } $field['allows_null'] = $field['allows_null'] ?? $crud->model::isColumnNullable($field['name']); $field['placeholder'] = $field['placeholder'] ?? trans('backpack::crud.select_entry'); @endphp @include('crud::fields.inc.wrapper_start') @include('crud::fields.inc.translatable_icon') {{-- 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 --}} @if ($crud->fieldTypeNotLoaded($field)) @php $crud->markFieldTypeAsLoaded($field); @endphp {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') {{-- include select2 css --}} @loadOnce('packages/select2/dist/css/select2.min.css') @loadOnce('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') @endpush {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') {{-- include select2 js --}} @loadOnce('packages/select2/dist/js/select2.full.min.js') @if (app()->getLocale() !== 'en') @loadOnce('packages/select2/dist/js/i18n/' . str_replace('_', '-', app()->getLocale()) . '.js') @endif @loadOnce('bpFieldInitSelect2Element') @endLoadOnce @endpush @endif {{-- End of Extra CSS and JS --}} {{-- ########################################## --}}