Created
April 13, 2012 11:26
-
-
Save weaverryan/2376058 to your computer and use it in GitHub Desktop.
Some basic Twitter Bootstrap Symfony2 form customizations
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
{# for twitter bootstrap specifically #} | |
{% block field_row %} | |
{% spaceless %} | |
<div class="control-group {% if errors|length > 0 %}error{% endif %}"> | |
{{ form_label(form, label|default(null)) }} | |
<div class="controls"> | |
{{ form_widget(form) }} | |
{{ form_errors(form)}} | |
</div> | |
</div> | |
{% endspaceless %} | |
{% endblock field_row %} | |
{% block field_errors %} | |
{% spaceless %} | |
{% if errors|length > 0 %} | |
{% for error in errors %} | |
<div class="help-inline"> | |
{{ error.messageTemplate|trans(error.messageParameters, 'validators') }} | |
</div> | |
{% endfor %} | |
{% endif %} | |
{% endspaceless %} | |
{% endblock field_errors %} | |
{# special errors block for form errors - at the top of the form, for example #} | |
{% block form_errors %} | |
{% spaceless %} | |
{% if errors|length > 0 %} | |
<div class="alert alert-error" style="display: inline-block;"> | |
{% for error in errors %} | |
{{ error.messageTemplate|trans(error.messageParameters, 'validators') }} | |
<br/> | |
{% endfor %} | |
</div> | |
{% endif %} | |
{% endspaceless %} | |
{% endblock form_errors %} | |
{% block generic_label %} | |
{% set attr = attr|merge({'class': ''}) %} | |
{% spaceless %} | |
{% if required %} | |
{% set attr = attr|merge({'class': 'required'}) %} | |
{% endif %} | |
<label{% for attrname,attrvalue in attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>{{ label|trans }}</label> | |
{% endspaceless %} | |
{% endblock %} | |
{# end twitter bootstrap stuff #} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment