Symfony ChoiceType 中的图标
我有一个 Symfony 表单,我尝试用不同的图标显示 SelectField
。
我的 ChoiceType 看起来像这样
->add('icon', ChoiceType::class, [
'choices' => [
'' => '',
'' => '',
],
'mapped' => false,
])
我的 CSS 看起来像这样
select { font-family: 'FontAwesome', Verdana }
当我渲染一个普通的选择 div 时,它工作得很好,我可以看到图标。
但是当通过 Symfony Form 尝试它时,它不起作用。我已经读过其他有同样问题的主题。一种解决方案是将 twig 的自动转义设置为 false 并尝试使用原始标签。但我仍然只看到纯文本“”,而不是选择框中的图标。
I have a Symfony Form and I try to display a SelectField
with different Icons.
My ChoiceType looks like this
->add('icon', ChoiceType::class, [
'choices' => [
'' => '',
'' => '',
],
'mapped' => false,
])
My CSS looks like this
select { font-family: 'FontAwesome', Verdana }
When I render a normal select div it works very well and i can see the icons.
But when try it via the Symfony Form it does not work. I have already read other Threads with the same problem. One solution was the to set the auto-escape of twig to false and try to work with the raw tag. But still i just see the pure text "" and not the Icons in the Select Box.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是,您可以使用
html_entity_decode
函数添加 css来执行此操作
One option, you can do this using the
html_entity_decode
functionadd css