{{-- select2 from ajax --}} @php $connected_entity = new $field['model']; $connected_entity_key_name = $connected_entity->getKeyName(); $old_value = old_empty_or_null($field['name'], false) ?? $field['value'] ?? $field['default'] ?? false; // by default set ajax query delay to 500ms // this is the time we wait before send the query to the search endpoint, after the user as stopped typing. $field['delay'] = $field['delay'] ?? 500; $field['allows_null'] = $field['allows_null'] ?? $crud->model::isColumnNullable($field['name']); $field['placeholder'] = $field['placeholder'] ?? trans('backpack::crud.select_entry'); $field['attribute'] = $field['attribute'] ?? $connected_entity->identifiableAttribute(); $field['minimum_input_length'] = $field['minimum_input_length'] ?? 2; @endphp @include('crud::fields.inc.wrapper_start') {{-- 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 --}} @loadOnce('packages/select2/dist/css/select2.min.css') @loadOnce('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') {{-- allow clear --}} @if($field['allows_null']) @loadOnce('select2_from_ajax_custom_css') @endLoadOnce @endif @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 @endpush {{-- include field specific select2 js --}} @push('crud_fields_scripts') @loadOnce('bpFieldInitSelect2FromAjaxElement') @endLoadOnce @endpush {{-- End of Extra CSS and JS --}} {{-- ########################################## --}}