Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sdieunidou/0f6b2254a26624ebbe1d19539b9e5691 to your computer and use it in GitHub Desktop.
Save sdieunidou/0f6b2254a26624ebbe1d19539b9e5691 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...
{% 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