Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c17df6e

Browse files
committed
[TwigBridge] add tailwindcss form layout
1 parent 906b609 commit c17df6e

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{% use 'form_div_layout.html.twig' %}
2+
3+
{%- block form_row -%}
4+
{%- set row_attr = row_attr|merge({ class: row_attr.class|default(row_class|default('mb-6')) }) -%}
5+
{{- parent() -}}
6+
{%- endblock form_row -%}
7+
8+
{%- block widget_attributes -%}
9+
{%- set attr = attr|merge({ class: attr.class|default(widget_class|default('mt-1 w-full')) ~ (disabled ? ' ' ~ widget_disabled_class|default('border-gray-300 text-gray-500')) ~ (errors|length ? ' ' ~ widget_errors_class|default('border-red-700')) }) -%}
10+
{{- parent() -}}
11+
{%- endblock widget_attributes -%}
12+
13+
{%- block form_label -%}
14+
{%- set label_attr = label_attr|merge({ class: label_attr.class|default(label_class|default('block text-gray-800')) }) -%}
15+
{{- parent() -}}
16+
{%- endblock form_label -%}
17+
18+
{%- block form_help -%}
19+
{%- set help_attr = help_attr|merge({ class: help_attr.class|default(help_class|default('mt-1 text-gray-600')) }) -%}
20+
{{- parent() -}}
21+
{%- endblock form_help -%}
22+
23+
{%- block form_errors -%}
24+
{%- if errors|length > 0 -%}
25+
<ul>
26+
{%- for error in errors -%}
27+
<li class="{{ error_item_class|default('text-red-700') }}">{{ error.message }}</li>
28+
{%- endfor -%}
29+
</ul>
30+
{%- endif -%}
31+
{%- endblock form_errors -%}
32+
33+
{%- block choice_widget_expanded -%}
34+
{%- set attr = attr|merge({ class: attr.class|default('mt-2') }) -%}
35+
<div {{ block('widget_container_attributes') }}>
36+
{%- for child in form %}
37+
<div class="flex items-center">
38+
{{- form_widget(child, { attr: { class: 'mr-2' } }) -}}
39+
{{- form_label(child, null, { translation_domain: choice_translation_domain }) -}}
40+
</div>
41+
{% endfor -%}
42+
</div>
43+
{%- endblock choice_widget_expanded -%}
44+
45+
{%- block checkbox_row -%}
46+
{%- set row_attr = row_attr|merge({ class: row_attr.class|default(row_class|default('mb-6')) }) -%}
47+
{%- set widget_attr = {} -%}
48+
{%- if help is not empty -%}
49+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
50+
{%- endif -%}
51+
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
52+
{{- form_errors(form) -}}
53+
<div class="inline-flex items-center">
54+
{{- form_widget(form, widget_attr) -}}
55+
{{- form_label(form) -}}
56+
</div>
57+
{{- form_help(form) -}}
58+
</div>
59+
{%- endblock checkbox_row -%}
60+
61+
{%- block checkbox_widget -%}
62+
{%- set widget_class = widget_class|default('mr-2') -%}
63+
{{- parent() -}}
64+
{%- endblock checkbox_widget -%}

0 commit comments

Comments
 (0)