Created
January 20, 2016 09:02
-
-
Save laurentsab/f04a75549b31b893f31c to your computer and use it in GitHub Desktop.
Twig merge attributes
This file contains hidden or 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
// parent_template.html.twig | |
{% include "AppBundle:fields:input_text.html.twig" with { | |
'form_id': form_id, | |
'field_name': 'Numéro', | |
'required': true, | |
'attr': { | |
'data-minlength': '\\d{7}', | |
'minlength': '7', | |
'maxlength': '7', | |
'data-error': 'e0.message_error'|trans() | |
}, | |
} %} | |
// input_text.html.twig | |
{{ form_widget(form_field, { | |
'attr': {'class': 'form-control margin_bottom_10px'}|merge( attr|default({}) ) } ) | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment