Open christian-lorenz opened 5 years ago
data-ajax-url
attribute has been changed to data-ajax--url
and support for the old attribute will be removed in future versions of Select2.". Themplate fields.html.twig has "'data-ajax--url':remote_path, ", but it seems that this correct part is not working. The solution was to copy fields.html.twig in project, and change "data-ajax--url" back to "data-ajax-url". Now remote_route works fine.
I'm using symfony 4.1, bootstrap 4.1.3, select2 4.0.6-rc.1 and select2-bootstrap4-theme 1.0.0@mvjuravlev can you tell me please, which steps are necessary to get this bundle working in symfony 4 with encore? Just fighting with that for hours :(
I'm using: Symfony 4.2.3 Select2 4.0.6-rc.1 Bootstrap v4.3.1 select2-bootstrap4-theme 1.0.0
app.scss
@import "~bootstrap/scss/bootstrap";
@import "~select2-bootstrap4-theme";
app.js
require('../css/app.scss');
global.$ = global.jQuery = require('jquery');
require('bootstrap');
require('select2');
base.html.twig
<head>
<meta charset="UTF-8">
<title>{% block title %}Portal{% endblock %}</title>
{{ encore_entry_link_tags('app') }}
{% block stylesheets %}
{% endblock %}
</head>
<body>
...
{{ encore_entry_script_tags('app') }}
{% block javascripts %}
<script src="{{ asset('bundles/tetranzselect2entity/js/select2entity.js') }}"></script>
{% endblock %}
</body>
twig.yaml
twig:
default_path: '%kernel.project_dir%/templates'
debug: '%kernel.debug%'
strict_variables: '%kernel.debug%'
form_themes:
- 'bootstrap_4_layout.html.twig'
- '@TetranzSelect2Entity/Form/fields.html.twig'
And it's looking like:
Thank you!
Just found the problem :)
{% block stylesheets %}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/css/select2.min.css" rel="stylesheet" />
{% endblock %}
Optionally
@import "~select2/dist/css/select2.min.css";
I missed to link the select2.css
I'm using https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js and asset('bundles/tetranzselect2entity/js/select2entity.js')