{{-- select2 from api --}} @php // set default values $value = old_empty_or_null($field['name'], false) ?? $field['value'] ?? $field['default'] ?? null; $value = is_string($value) ? json_decode($value) : $value; $value = is_object($value) || (is_array($value) && is_string(key($value))) ? [$value] : $value; $field['placeholder'] ??= trans('backpack::crud.select_entry'); $field['minimum_input_length'] ??= 2; $field['delay'] ??= 500; $field['allows_null'] ??= $crud->model::isColumnNullable($field['name']); $field['dependencies'] ??= []; $field['method'] ??= 'GET'; $field['include_all_form_fields'] ??= false; $field['multiple'] ??= false; $field['attributes_to_store'] ??= [$field['attribute'] ?? 'text', 'id']; $field['attribute'] ??= current($field['attributes_to_store']); $field['closeOnSelect'] ??= !$field['multiple']; $disabled = in_array('disabled', $field['attributes'] ?? []); @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 --}} {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') {{-- include select2 css --}} @basset('https://unpkg.com/select2@4.0.13/dist/css/select2.min.css') @basset('https://unpkg.com/select2-bootstrap-theme@0.1.0-beta.10/dist/select2-bootstrap.min.css') @endpush {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') {{-- include select2 js --}} @basset('https://unpkg.com/select2@4.0.13/dist/js/select2.full.min.js') @if (app()->getLocale() !== 'en') @basset('https://unpkg.com/select2@4.0.13/dist/js/i18n/' . str_replace('_', '-', app()->getLocale()) . '.js') @endif @endpush {{-- include field specific select2 js --}} @push('crud_fields_scripts') @bassetBlock('backpack/pro/fields/select2-from-api-field.js') @endBassetBlock @endpush {{-- End of Extra CSS and JS --}} {{-- ########################################## --}}