Skip to content

Commit

Permalink
Define columns in form builder
Browse files Browse the repository at this point in the history
widget_col, label_col and simple_col can be defined as attribute in form builder
  • Loading branch information
Florian Eckerstorfer committed Nov 5, 2013
1 parent a0644c9 commit c8bbab4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Resources/config/services/form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<services>

<service id="braincrafted_bootstrap.form.type.collection" class="%braincrafted_bootstrap.form.type.collection.class%">
<tag name="form.type" alias="braincrafted_collection" />
<tag name="form.type" alias="bootstrap_collection" />
</service>

<service id="braincrafted_bootstrap.form.type.money" class="%braincrafted_bootstrap.form.type.money.class%">
Expand Down
50 changes: 48 additions & 2 deletions Resources/views/Form/form_div_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}

{% if attr.simple_col is defined and attr.simple_col is not empty %}
{% set simple_col = attr.simple_col %}
{% endif %}

{% if simple_col is defined %}
<div class="col-lg-{{ simple_col }}">
{% endif %}
Expand Down Expand Up @@ -60,7 +64,7 @@
{% endspaceless %}
{% endblock collection_widget %}

{% block braincrafted_collection_widget %}
{% block bootstrap_collection_widget %}
{% spaceless %}
{% if prototype is defined %}
{% set prototype_vars = {} %}
Expand Down Expand Up @@ -98,7 +102,7 @@
{% endif %}
</div>
{% endspaceless %}
{% endblock braincrafted_collection_widget %}
{% endblock bootstrap_collection_widget %}

{% block textarea_widget %}
{% spaceless %}
Expand All @@ -110,6 +114,10 @@

{% block file_widget %}
{% spaceless %}
{% if attr.simple_col is defined and attr.simple_col is not empty %}
{% set simple_col = attr.simple_col %}
{% endif %}

{% if simple_col is defined %}
<div class="col-lg-{{ simple_col }}">
{% endif %}
Expand Down Expand Up @@ -186,6 +194,13 @@
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}

{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}

{% set class = '' %}
{% if align_with_widget is defined or attr.align_with_widget is defined %}
{% set widget_col = widget_col|default(10) %}
Expand Down Expand Up @@ -225,6 +240,14 @@
{% block radio_row %}
{% spaceless %}
{% set class = '' %}

{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}

{% if align_with_widget is defined or attr.align_with_widget is defined %}
{% set widget_col = widget_col|default(10) %}
{% set label_col = label_col|default(2) %}
Expand Down Expand Up @@ -423,6 +446,13 @@

{% block form_label %}
{% spaceless %}
{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}

{% if label is not sameas(false) %}
{% set style = style|default(bootstrap_get_style()) %}
{% set label_col = label_col|default(2) %}
Expand Down Expand Up @@ -465,6 +495,14 @@
{% block form_row %}
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}

{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}

{% set label_col = label_col|default(2) %}
{% set widget_col = widget_col|default(10) %}

Expand Down Expand Up @@ -537,6 +575,14 @@
{% block button_row %}
{% spaceless %}
{% set style = style|default(bootstrap_get_style()) %}

{% if attr.label_col is defined and attr.label_col is not empty %}
{% set label_col = attr.label_col %}
{% endif %}
{% if attr.widget_col is defined and attr.widget_col is not empty %}
{% set widget_col = attr.widget_col %}
{% endif %}

{% set label_col = label_col|default(2) %}
{% set widget_col = widget_col|default(10) %}

Expand Down

0 comments on commit c8bbab4

Please sign in to comment.