Created
November 23, 2012 21:54
-
-
Save marijn/4137467 to your computer and use it in GitHub Desktop.
This is how you add a link to a label with Symfony forms, sort of. Cause you'll have a label tag twice...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set terms_link %}<a title="{% trans %}Read the General Terms and Conditions{% endtrans %}" href="{{ path('get_general_terms_and_conditions') }}">{% trans %}General Terms and Conditions{% endtrans %}</a>{% endset %} | |
{% set general_terms_and_conditions %}{{ 'I have read and accept the %general_terms_and_conditions%.'|trans({ '%general_terms_and_conditions%': terms_link })|raw }}{% endset %} | |
<div> | |
{{ form_errors(form.acceptGeneralTermsAndConditions) }} | |
{{ form_widget(form.acceptGeneralTermsAndConditions) }} | |
<label for="{{ form.acceptGeneralTermsAndConditions.vars.id }}">{{ general_terms_and_conditions|raw }}</label> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@marijn thanks for sharing this, Mr Google took me here 6 years later, for anyone else looking how to achieve in the current symfony4 and bootstrap4 the label is now rendered from within the
form_widget
call, overriding theform_label
appears to be buggy at the moment: symfony/symfony#28823