Reviewed & tested by the community
Project:
Select 2
Version:
8.x-1.13
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Jun 2021 at 18:07 UTC
Updated:
16 Apr 2024 at 14:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #6
giorgoskWorkaround: If one updates all view fields and changes in the style section
Customize field and label wrapper HTML
Customize label HTML
Customize field HTML
and sets the Element to none, no HTML is passed to select2 and there is no need for this patch.
Comment #7
chr.fritschI think the workaround from @GiorgosK is fine. If you think select2 should do some additional work, feel free to reopen the issue.
Comment #8
giorgoskSo technically this should be works as designed
Comment #9
kostiantyn@tuuuukka When I apply the patch, I encounter the error
"TypeError: undefined is not an object (evaluating 'drupalSettings.select2.htmlAsText')". The error disappears when I set the configuration for the field, but it's not very convenient to set these settings for every field, even for those where these values are not needed.Comment #10
duwid commentedI'm working on a case where I need to keep and render the html from select2 results, instead of removing it as described in @GiorgosK workaround. Therefore I will open this issue again, because I think the implemented solution from @Tuuuukka is a great improvement. I just found a little issue in select2.js:
if (drupalSettings.select2.htmlAsText === false) {htmlAsText is int 0, so it should be:
if (drupalSettings.select2.htmlAsText === 0) {Comment #11
duwid commentedComment #12
kostiantyn@Duwid, thank you for your improvement, I am testing it right now.
Comment #13
kostiantynComment #14
duwid commentedThis patch robustifys implementation if htmlAsText is not available because select2 widget is programmatically implemented via form api. For example this is the case social group invite module.