I'm using Symfony 4 and Virtual Select, "A javascript plugin for dropdown with virtual scroll".
By default, when Symfony renders a multiple select, the HTML code looks like this :
<select multiple="multiple">
However, Virtual Select seems very picky, and only behaves properly if the multiple attribute doesn't have a value, like this :
<select multiple>
(Which, as far as I know, is the "official" syntax, multiple="multiple" isn't mentioned by Mozilla for example.)
Is there there a way to force Symfony to use the second syntax instead of the first ?
I thought of a few workaround which wouldn't work :
- Writing the whole HTML myself wouldn't be practical as it is very long (hence Virtual Select).
- I tried passing the "multiple" option in Javascript as described here, but that has no effect if the the multiple attribute with the wrong syntax is still present in the HTML.
- I could replace Virtual Select, but I would rather not as it is already used in many other places.
CodePudding user response:
In the end I used a workaround in javascript :
document.getElementById('select#whatever').setAttribute('multiple','');
Which seems to satisfy Virtual Select.
(And then I had to pile up more workarounds for other issues between Virtual Select and Symfony. All in all, you probably should avoid using those two together.)