|
<!-- select2 multiple --> |
|
<div @include('crud::inc.field_wrapper_attributes') > |
|
<label>{!! $field['label'] !!}</label> |
|
|
|
|
|
|
|
|
|
<select |
|
name="{{ $field['name'] }}[]" |
|
@include('crud::inc.field_attributes', ['default_class' => 'form-control select2_tags']) |
|
multiple> |
|
@if (isset($field['model'])) |
|
|
|
@foreach ($field['model']::all() as $connected_entity_entry) |
|
|
|
<option value="{{ $connected_entity_entry->{$field['attribute']['key']} }}" |
|
@if ( |
|
( |
|
isset($entry) && in_array($connected_entity_entry->{$field['attribute']['key']}, $entry->tagList()) |
|
) || ( |
|
old( $field["name"] ) && in_array($connected_entity_entry->{$field['attribute']['key']}, old( $field["name"])) |
|
) |
|
) |
|
selected |
|
@endif |
|
>{{ $connected_entity_entry->{$field['attribute']['value']} }}</option> |
|
@endforeach |
|
@endif |
|
</select> |
|
|
|
{{-- HINT --}} |
|
@if (isset($field['hint'])) |
|
<p class="help-block">{!! $field['hint'] !!}</p> |
|
@endif |
|
</div> |
|
|
|
|
|
{{-- ########################################## --}} |
|
{{-- 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->checkIfFieldIsFirstOfItsType($field, $fields)) |
|
|
|
{{-- FIELD CSS - will be loaded in the after_styles section --}} |
|
@push('crud_fields_styles') |
|
<!-- include select2 css--> |
|
<link rel="stylesheet" href="{{ elixir('css/select2.css') }}"> |
|
<!--link href="{{ asset('vendor/backpack/select2/select2.css') }}" rel="stylesheet" type="text/css" /--> |
|
<!--link href="{{ asset('vendor/backpack/select2/select2-bootstrap-dick.css') }}" rel="stylesheet" type="text/css" /--> |
|
@endpush |
|
|
|
{{-- FIELD JS - will be loaded in the after_scripts section --}} |
|
@push('crud_fields_scripts') |
|
<!-- include select2 js--> |
|
<script src="{{ elixir('js/select2.js') }}"></script> |
|
<!-- script src="{{ asset('vendor/backpack/select2/select2.js') }}"></script --> |
|
<script> |
|
jQuery(document).ready(function($) { |
|
// trigger select2 for each untriggered select2_multiple box |
|
$('.select2_tags').each(function (i, obj) { |
|
if (!$(obj).data("select2")) |
|
{ |
|
$(obj).select2({ |
|
tags : true, |
|
tokenSeparators: [','], |
|
placeholder: "Add your tags here", |
|
theme: "bootstrap" |
|
}); |
|
} |
|
}); |
|
}); |
|
</script> |
|
@endpush |
|
|
|
@endif |
|
{{-- End of Extra CSS and JS --}} |
|
{{-- ########################################## --}} |