Created
May 24, 2013 16:53
-
-
Save FlYos/5644881 to your computer and use it in GitHub Desktop.
Special form theme symfony2 for use horizontal form with twitter bootstrap
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
{% extends "form_div_layout.html.twig" %} | |
{% block form_errors %} | |
{% spaceless %} | |
{% if errors|length > 0 %} | |
{% for error in errors %} | |
<label class="error">{{ error.message }}</label> | |
{% endfor %} | |
{% endif %} | |
{% endspaceless %} | |
{% endblock form_errors %} | |
{% block form_label %} | |
{% spaceless %} | |
{% set label_attr = label_attr|merge({'class':(label_attr.class|default('') ~ ' control-label')}) %} | |
{% if not compound %} | |
{% set label_attr = label_attr|merge({'for': id}) %} | |
{% endif %} | |
{% if required %} | |
{% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} | |
{% endif %} | |
{% if label is empty %} | |
{% set label = name|humanize %} | |
{% endif %} | |
{% if form.vars.block_prefixes.2 not in ['checkbox', 'radio'] %} | |
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}> | |
{{ id|trans({}, 'forms') }} | |
{% if required %} | |
<span class="f_req" title="{% trans %}Ce champs est obligatoire{% endtrans %}">*</span> | |
{% endif %} | |
</label> | |
{% endif %} | |
{% endspaceless %} | |
{% endblock form_label %} | |
{% block checkbox_widget %} | |
{% spaceless %} | |
<label class="checkbox"> | |
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> | |
{{ label|trans({}, 'forms') }} | |
</label> | |
{% endspaceless %} | |
{% endblock checkbox_widget %} | |
{% block radio_widget %} | |
{% spaceless %} | |
<label class="radio"> | |
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> | |
{{ label|trans({}, 'forms') }} | |
</label> | |
{% endspaceless %} | |
{% endblock radio_widget %} | |
{% block form_row %} | |
{% spaceless %} | |
<div class="control-group{% if errors|length > 0 %} f_error{% endif %}"> | |
{{ form_label(form) }} | |
<div class="controls"> | |
{{ form_widget(form) }} | |
{{ form_errors(form) }} | |
</div> | |
</div> | |
{% endspaceless %} | |
{% endblock %} | |
{% block form_widget_simple %} | |
{% spaceless %} | |
{% set type = type|default('text') %} | |
{% set prepend = prepend|default(false) %} | |
{% set append = append|default(false) %} | |
{% if append or prepend %} | |
<div class="{% if append %}input-append{% endif %} {% if prepend %}input-prepend{% endif %}"> | |
{% if prepend %}<span class="add-on">{{ preprend|raw }}</span>{% endif %} | |
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/> | |
{% if append %}<span class="add-on">{{ append|raw }}</span>{% endif %} | |
</div> | |
{% else %} | |
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/> | |
{% endif %} | |
{% endspaceless %} | |
{% endblock form_widget_simple %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment