admin管理员组文章数量:1391987
I am building the Symfony form with a CollectionType field. The application logic assumes that new items can be added. To be short in explanation what is done, I am providing the link from the official docs. Consider my setting is just the same. .html#javascript-with-stimulus
The actual problem is when I pass the prototype to stimulus controller like this:
<div {{stimulus_controller(‘url-manager’, {prototype: form_row(prototype)|e(‘html_attr’)})}}></div>
And then in controller creating new element, setting its innerHTML to this.prototypeValue, it is being inserted as text, not html element.
However, if I do pass the prototype without applying filter |e, all works fine.
Could anyone advise if this is due to some change not being reflected in the docs? Or maybe the stimulus_controller()
helper function applies some additional filtering?
The helper function is the only difference of my implementation from the docs.
I am building the Symfony form with a CollectionType field. The application logic assumes that new items can be added. To be short in explanation what is done, I am providing the link from the official docs. Consider my setting is just the same. https://symfony/doc/current/form/form_collections.html#javascript-with-stimulus
The actual problem is when I pass the prototype to stimulus controller like this:
<div {{stimulus_controller(‘url-manager’, {prototype: form_row(prototype)|e(‘html_attr’)})}}></div>
And then in controller creating new element, setting its innerHTML to this.prototypeValue, it is being inserted as text, not html element.
However, if I do pass the prototype without applying filter |e, all works fine.
Could anyone advise if this is due to some change not being reflected in the docs? Or maybe the stimulus_controller()
helper function applies some additional filtering?
The helper function is the only difference of my implementation from the docs.
Share Improve this question edited Mar 13 at 6:43 DarkBee 15.5k8 gold badges72 silver badges118 bronze badges asked Mar 12 at 21:41 MaxMax 12 bronze badges1 Answer
Reset to default 0Actually I found in the docs, that stimulus_controller() helper function escapes all non-scalar values, thus it is better to declare values in a straight forward attribute style.
data-controller="url-manager"
data-url-manager-prototype-value="{{ form_row(prototype)|e('html_attr') }}"
本文标签: symfonyHow to pass prototype to Stimulus controllerStack Overflow
版权声明:本文标题:symfony - How to pass prototype to Stimulus controller? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744729333a2621953.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论