You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,7 @@ If text_property is omitted then the entity is cast to a string. This requires i
138
138
*`autostart` Determines whether or not the select2 jQuery code is called automatically on document ready. Defaults to true which provides normal operation.
139
139
*`width` Sets a data-width attribute if not null. Defaults to null.
140
140
*`class_type` Optional value that will be added to the ajax request as a query string parameter.
141
+
*`render_html` This will render your results returned under ['html'].
141
142
142
143
The url of the remote query can be given by either of two ways: `remote_route` is the Symfony route.
143
144
`remote_params` can be optionally specified to provide parameters. Alternatively, `remote_path` can be used to specify
@@ -158,6 +159,7 @@ tetranz_select2_entity:
158
159
cache_timeout: 0
159
160
scroll: true
160
161
object_manager: 'manager_alias'
162
+
render_html: true
161
163
```
162
164
163
165
## AJAX Response
@@ -340,6 +342,15 @@ Because the handling of requests is usually very similar you can use a service w
340
342
341
343
### Templating
342
344
345
+
General templating has now been added to the bundle. If you need to render html code inside your selection results, set the `render_html` option to true and in your controller return data like this:
<details><summary>If you need further templating, you'll need to override the .select2entity() method as follows.</summary>
343
354
If you need [Templating](https://select2.org/dropdown#templating) in Select2, you could consider the following example that shows the country flag next to each option.
344
355
345
356
Your custom transformer should return data like this:
@@ -395,7 +406,7 @@ You also will need to override the following block in your template:
395
406
</option>
396
407
{% endblock %}
397
408
```
398
-
This block adds all additional data needed to the JavaScript function `select2entityAjax`, like data attribute. In this case we are passing `data-img`.
409
+
This block adds all additional data needed to the JavaScript function `select2entityAjax`, like data attribute. In this case we are passing `data-img`.</details>
399
410
400
411
## Embed Collection Forms
401
412
If you use [Embedded Collection Forms](http://symfony.com/doc/current/cookbook/form/form_collections.html) and [data-prototype](http://symfony.com/doc/current/cookbook/form/form_collections.html#allowing-new-tags-with-the-prototype) to add new elements in your form, you will need the following JavaScript that will listen for adding an element `.select2entity`:
0 commit comments