diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig new file mode 100644 index 000000000000..6fc226da4fce --- /dev/null +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_horizontal_layout.html.twig @@ -0,0 +1,72 @@ +{% extends "bootstrap_3_layout.html.twig" %} + +{% block form_start -%} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %} + {{- parent() -}} +{%- endblock form_start %} + +{# Labels #} + +{% block form_label -%} +{% spaceless %} + {% if label is sameas(false) %} +
+ {% else %} + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %} + {{- parent() -}} + {% endif %} +{% endspaceless %} +{%- endblock form_label %} + +{% block form_label_class -%} +col-sm-2 +{%- endblock form_label_class %} + +{# Rows #} + +{% block form_row -%} +{% spaceless %} +
+ {{ form_label(form) }} +
+ {{ form_widget(form) }} + {{ form_errors(form) }} +
+
+{% endspaceless %} +{%- endblock form_row %} + +{% block checkbox_row -%} + {{- block('checkbox_radio_row') -}} +{%- endblock checkbox_row %} + +{% block radio_row -%} + {{- block('checkbox_radio_row') -}} +{%- endblock radio_row %} + +{% block checkbox_radio_row -%} +{% spaceless %} +
+
+
+ {{ form_widget(form) }} + {{ form_errors(form) }} +
+
+{% endspaceless %} +{%- endblock checkbox_radio_row %} + +{% block submit_row -%} +{% spaceless %} +
+
+
+ {{ form_widget(form) }} +
+
+{% endspaceless %} +{% endblock submit_row %} + +{% block form_group_class -%} +col-sm-10 +{%- endblock form_group_class %} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig new file mode 100644 index 000000000000..db0971f3827e --- /dev/null +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/bootstrap_3_layout.html.twig @@ -0,0 +1,231 @@ +{% extends "form_div_layout.html.twig" %} + +{# Widgets #} + +{% block form_widget_simple -%} + {% if type is not defined or 'file' != type %} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} + {% endif %} + {{- parent() -}} +{%- endblock form_widget_simple %} + +{% block textarea_widget -%} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} + {{- parent() -}} +{%- endblock textarea_widget %} + +{% block submit_widget -%} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %} + {{- parent() -}} +{%- endblock %} + +{% block button_widget -%} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' btn')|trim}) %} + {{- parent() -}} +{%- endblock %} + +{% block money_widget -%} +
+ {% set prepend = '{{' == money_pattern[0:2] %} + {% if not prepend %} + {{ money_pattern|replace({ '{{ widget }}':''}) }} + {% endif %} + {{- block('form_widget_simple') -}} + {% if prepend %} + {{ money_pattern|replace({ '{{ widget }}':''}) }} + {% endif %} +
+{%- endblock money_widget %} + +{% block percent_widget -%} +
+ {{- block('form_widget_simple') -}} + % +
+{%- endblock percent_widget %} + +{% block datetime_widget -%} + {% if widget == 'single_text' %} + {{- block('form_widget_simple') -}} + {% else %} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} +
+ {{ form_errors(form.date) }} + {{ form_errors(form.time) }} + {{ form_widget(form.date, { datetime: true } ) }}  + {{ form_widget(form.time, { datetime: true } ) }} +
+ {% endif %} +{%- endblock datetime_widget %} + +{% block date_widget -%} + {% if widget == 'single_text' %} + {{- block('form_widget_simple') -}} + {% else %} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} + {% if datetime is not defined or not datetime %} +
+ {% endif %} + {{ date_pattern|replace({ + '{{ year }}': form_widget(form.year), + '{{ month }}': form_widget(form.month), + '{{ day }}': form_widget(form.day), + })|raw }} + {% if datetime is not defined or not datetime %} +
+ {% endif %} + {% endif %} +{%- endblock date_widget %} + +{% block time_widget -%} + {% if widget == 'single_text' %} + {{- block('form_widget_simple') -}} + {% else %} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) %} + {% if datetime is not defined or false == datetime %} +
+ {% endif %} + {{ form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %} + {% if datetime is not defined or false == datetime %} +
+ {% endif %} + {% endif %} +{%- endblock time_widget %} + +{% block choice_widget_collapsed -%} + {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} + {{- parent() -}} +{%- endblock %} + +{% block choice_widget_expanded -%} + {% if '-inline' in label_attr.class|default('') %} +
+ {% for child in form %} + {{ form_widget(child, { + parent_label_class: label_attr.class|default(''), + }) }} + {% endfor %} +
+ {% else %} +
+ {% for child in form %} + {{ form_widget(child, { + parent_label_class: label_attr.class|default(''), + }) }} + {% endfor %} +
+ {% endif %} +{%- endblock choice_widget_expanded %} + +{% block checkbox_widget -%} + {% set parent_label_class = parent_label_class|default('') %} + {% if 'checkbox-inline' in parent_label_class %} + {{ form_label(form, null, { widget: parent() }) }} + {% else %} +
+ {{ form_label(form, null, { widget: parent() }) }} +
+ {% endif %} +{%- endblock checkbox_widget %} + +{% block radio_widget -%} + {% set parent_label_class = parent_label_class|default('') %} + {% if 'radio-inline' in parent_label_class %} + {{ form_label(form, null, { widget: parent() }) }} + {% else %} +
+ {{ form_label(form, null, { widget: parent() }) }} +
+ {% endif %} +{%- endblock radio_widget %} + +{# Labels #} + +{% block form_label -%} + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) %} + {{- parent() -}} +{%- endblock form_label %} + +{% block choice_label %} + {# remove the checkbox-inline, it's only use full for embed labels #} + {% set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': ''})|trim}) %} + {{- block('form_label') -}} +{% endblock %} + +{% block checkbox_label -%} + {{- block('checkbox_radio_label') -}} +{%- endblock checkbox_label %} + +{% block radio_label -%} + {{- block('checkbox_radio_label') -}} +{%- endblock radio_label %} + +{% block checkbox_radio_label %} + {% if required %} + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} + {% endif %} + {% if parent_label_class is defined %} + {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|trim}) %} + {% endif %} + {% if label is empty %} + {% set label = name|humanize %} + {% endif %} + + {{ widget|raw }} + {{ label|trans({}, translation_domain) }} + +{% endblock checkbox_radio_label %} + +{# Rows #} + +{% block form_row -%} +
+ {{ form_label(form) }} + {{ form_widget(form) }} + {{ form_errors(form) }} +
+{%- endblock form_row %} + +{% block choice_row -%} + {% set force_error = true %} + {{ block('form_row') }} +{%- endblock choice_row %} + +{% block date_row -%} + {% set force_error = true %} + {{ block('form_row') }} +{%- endblock date_row %} + +{% block time_row -%} + {% set force_error = true %} + {{ block('form_row') }} +{%- endblock time_row %} + +{% block datetime_row -%} + {% set force_error = true %} + {{ block('form_row') }} +{%- endblock datetime_row %} + +{% block checkbox_row -%} +
+ {{ form_widget(form) }} + {{ form_errors(form) }} +
+{%- endblock checkbox_row %} + +{% block radio_row -%} +
+ {{ form_widget(form) }} + {{ form_errors(form) }} +
+{%- endblock radio_row %} + +{# Errors #} + +{% block form_errors -%} + {% if errors|length > 0 %} + {% if form.parent %}{% else %}
{% endif %} + {{- parent() -}} + {% if form.parent %}{% else %}
{% endif %} + {% endif %} +{%- endblock form_errors %}