I've only recently started using Symfony (Symfony3) and I'm in the process of converting my old website to use Symfony. Currently with my form elements I have the addition of a validation error message element, plus a help/information element (an info symbol that shows the text on clicking).
<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 handles the validation error message element as standard but I can't see a way of easily adding extra info text. Ideally I would like this as an extra option I can then pass to the 'add' method of the FormBuilder. E.g.
->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>'
)
Is that possible? Rather than adding it directly in my twig templates.
Try the following :
->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>'
)
If it doesn't work on this field type, look at the following form extension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With