gpt4 book ai didi

php - Symfony FormBuilder - 附加元素的自定义选项?

转载 作者:搜寻专家 更新时间:2023-10-31 21:26:21 24 4
gpt4 key购买 nike

我最近才开始使用 Symfony (Symfony3),并且正在将我的旧网站转换为使用 Symfony。目前,在我的表单元素中,我添加了一个验证错误消息元素,以及一个帮助/信息元素(一个在点击时显示文本的信息符号)。

<div id="info-username" class="additional-info">
<p>Your username will be used as a way of <em>uniquely</em> identifying you when you log into your account. You can still log in using your email address in case you forget your username.</p>
<p>It must be between 2-25 characters long and start with a letter. The following characters are permitted: letter, number, dot, underscore, dash.</p>
</div>

Symfony 按照标准处理验证错误消息元素,但我看不到轻松添加额外信息文本的方法。理想情况下,我希望这是一个额外的选项,然后我可以将其传递给 FormBuilder 的“添加”方法。例如

->add('username', TextType::class, array(
'info' => '<p>Your username will be used as a way of <em>uniquely</em> identifying you when you log into your account. You can still log in using your email address in case you forget your username.</p>
<p>It must be between 2-25 characters long and start with a letter. The following characters are permitted: letter, number, dot, underscore, dash.</p>'
)

这可能吗?而不是直接将它添加到我的 Twig 模板中。

最佳答案

尝试以下操作:

->add('username', TextType::class, array(
'help' => '<p>Your username will be used as a way of <em>uniquely</em> identifying you when you log into your account. You can still log in using your email address in case you forget your username.</p>
<p>It must be between 2-25 characters long and start with a letter. The following characters are permitted: letter, number, dot, underscore, dash.</p>'
)

如果它不适用于此字段类型,请查看 the following form extension

关于php - Symfony FormBuilder - 附加元素的自定义选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35368515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com