如何自定义“多倍” SYMFONY中选择标签的属性
我正在使用Symfony 4和 virtual select 插件,用于下拉插件,使用虚拟滚动”。
默认情况下,当Symfony呈现多个选择时,HTML代码看起来像这样:
<select multiple="multiple">
但是,Virtual Select似乎非常挑剔,并且只有当多个属性没有值的情况下才能正确地行为,例如:(
<select multiple>
就我而言,它知道,是“官方”语法,多=“多个”未提及 mozilla
。 :
- 编写整个HTML本人并不实用,因为它很长(因此选择)。
- 我尝试在JavaScript中传递“多个”选项,如所述在这里,但是如果HTML中仍然存在错误的语法的多个属性,那将没有效果。
- 我可以替换虚拟选择,但是我不想在其他许多地方使用它,因为它已经使用了。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我在JavaScript中使用了一个解决方法:
似乎满足虚拟选择。
(然后,我不得不为虚拟选择和符号之间的其他问题堆积更多解决方法。总而言之,您可能应该避免将这两者一起使用。)
In the end I used a workaround in javascript :
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.)