8000 feature #20887 [Form] DateIntervalType: Allow to configure labels & e… · symfony/twig-bridge@706a17f · GitHub
[go: up one dir, main page]

Skip to content

Commit 706a17f

Browse files
committed
feature #20887 [Form] DateIntervalType: Allow to configure labels & enhance form theme (ogizanagi)
This PR was merged into the 3.3-dev branch. Discussion ---------- [Form] DateIntervalType: Allow to configure labels & enhance form theme | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no (unless someone relies on this non themed type) | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | Should document the new `labels` option I just realized by using it for last fixes in #20886 and #20877 that this type was not really themed: ### before <img width="861" alt="screenshot 2016-12-13 a 00 54 35" src="https://cloud.githubusercontent.com/assets/2211145/21121792/c589d27a-c0ce-11e6-8368-a396fda3bc7a.PNG"> At least labels should appear, but this also means being able to change them (thus the new `labels` option). I think the form themes should provide a functional & minimalistic integration like this: ### after <img width="862" alt="screenshot 2016-12-13 a 00 54 17" src="https://cloud.githubusercontent.com/assets/2211145/21121814/d9c4ead6-c0ce-11e6-94e1-41e6c14884a7.PNG"> --- (On screenshots above, I've only added a css rule to remove the 100% width of the `.table` class. See symfony/symfony#20887 (comment)) Commits ------- bfd9e50bbb [Form] DateIntervalType: Allow to configure labels & enhance form theme
2 parents 3a81b79 + 3d6e2b0 commit 706a17f

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

Resources/views/Form/bootstrap_3_layout.html.twig

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,32 @@
9494
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
9595
<div {{ block('widget_container_attributes') }}>
9696
{{- form_errors(form) -}}
97-
{%- if with_years %}{{ form_widget(form.years) }}{% endif -%}
98-
{%- if with_months %}{{ form_widget(form.months) }}{% endif -%}
99-
{%- if with_weeks %}{{ form_widget(form.weeks) }}{% endif -%}
100-
{%- if with_days %}{{ form_widget(form.days) }}{% endif -%}
101-
{%- if with_hours %}{{ form_widget(form.hours) }}{% endif -%}
102-
{%- if with_minutes %}{{ form_widget(form.minutes) }}{% endif -%}
103-
{%- if with_seconds %}{{ form_widget(form.seconds) }}{% endif -%}
97+
<div class="table-responsive">
98+
<table class="table {{ table_class|default('table-bordered table-condensed table-striped') }}">
99+
<thead>
100+
<tr>
101+
{%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}
102+
{%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%}
103+
{%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%}
104+
{%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%}
105+
{%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%}
106+
{%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%}
107+
{%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%}
108+
</tr>
109+
</thead>
110+
<tbody>
111+
<tr>
112+
{%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%}
113+
{%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%}
114+
{%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%}
115+
{%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%}
116+
{%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%}
117+
{%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%}
118+
{%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%}
119+
</tr>
120+
</tbody>
121+
</table>
122+
</div>
104123
{%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
105124
</div>
106125
{%- endif -%}

Resources/views/Form/form_div_layout.html.twig

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,30 @@
136136
{%- else -%}
137137
<div {{ block('widget_container_attributes') }}>
138138
{{- form_errors(form) -}}
139-
{%- if with_years %}{{ form_widget(form.years) }}{% endif -%}
140-
{%- if with_months %}{{ form_widget(form.months) }}{% endif -%}
141-
{%- if with_weeks %}{{ form_widget(form.weeks) }}{% endif -%}
142-
{%- if with_days %}{{ form_widget(form.days) }}{% endif -%}
143-
{%- if with_hours %}{{ form_widget(form.hours) }}{% endif -%}
144-
{%- if with_minutes %}{{ form_widget(form.minutes) }}{% endif -%}
145-
{%- if with_seconds %}{{ form_widget(form.seconds) }}{% endif -%}
139+
<table class="{{ table_class|default('') }}">
140+
<thead>
141+
<tr>
142+
{%- if with_years %}<th>{{ form_label(form.years) }}</th>{% endif -%}
143+
{%- if with_months %}<th>{{ form_label(form.months) }}</th>{% endif -%}
144+
{%- if with_weeks %}<th>{{ form_label(form.weeks) }}</th>{% endif -%}
145+
{%- if with_days %}<th>{{ form_label(form.days) }}</th>{% endif -%}
146+
{%- if with_hours %}<th>{{ form_label(form.hours) }}</th>{% endif -%}
147+
{%- if with_minutes %}<th>{{ form_label(form.minutes) }}</th>{% endif -%}
148+
{%- if with_seconds %}<th>{{ form_label(form.seconds) }}</th>{% endif -%}
149+
</tr>
150+
</thead>
151+
<tbody>
152+
<tr>
153+
{%- if with_years %}<td>{{ form_widget(form.years) }}</td>{% endif -%}
154+
{%- if with_months %}<td>{{ form_widget(form.months) }}</td>{% endif -%}
155+
{%- if with_weeks %}<td>{{ form_widget(form.weeks) }}</td>{% endif -%}
156+
{%- if with_days %}<td>{{ form_widget(form.days) }}</td>{% endif -%}
157+
{%- if with_hours %}<td>{{ form_widget(form.hours) }}</td>{% endif -%}
158+
{%- if with_minutes %}<td>{{ form_widget(form.minutes) }}</td>{% endif -%}
159+
{%- if with_seconds %}<td>{{ form_widget(form.seconds) }}</td>{% endif -%}
160+
</tr>
161+
</tbody>
162+
</table>
146163
{%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
147164
</div>
148165
{%- endif -%}

0 commit comments

Comments
 (0)
0