Skip to content

Commit edd621e

Browse files
author
Thomas Jarrand
committed
Added form theme + breadcrumb component
1 parent 6b54af7 commit edd621e

2 files changed

Lines changed: 140 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% block breadcrumb %}
2+
<ul class="breadcrumb">
3+
{% for item in breadcrumb %}
4+
{% if loop.last %}
5+
<li class="breadcrumb__item">
6+
<span>{{ item.label|default(item) }}</span>
7+
</li>
8+
{% else %}
9+
<li class="breadcrumb__item">
10+
<a href="{{ menu_path(item) }}">
11+
{{ item.label }}
12+
</a>
13+
</li>
14+
{% endif %}
15+
{% endfor %}
16+
</ul>
17+
{% endblock %}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{% use 'form_div_layout.html.twig' %}
2+
3+
{% set translation_domain = 'forms' %}
4+
5+
{%- block form_widget_compound -%}
6+
{% if form.parent != null %}<div {{ block('widget_container_attributes') }}>{% endif %}
7+
{%- if form is rootform -%}
8+
{{ form_errors(form) }}
9+
{%- endif -%}
10+
{{- block('form_rows') -}}
11+
{{- form_rest(form) -}}
12+
{% if form.parent != null %}</div>{% endif %}
13+
{%- endblock form_widget_compound -%}
14+
15+
{%- block choice_widget_collapsed -%}
16+
{% set classique_select = not multiple and not attr['data-choice']|default(false) %}
17+
{% if classique_select %}<div class="select">{% endif %}
18+
{{- parent() -}}
19+
{% if classique_select %}</div>{% endif %}
20+
{%- endblock -%}
21+
22+
{%- block form_row -%}
23+
{%- set row_class = row_class|default('form') -%}
24+
{%- set row_attr = row_attr|merge({ class: row_class ~ (errors|length > 0 ? ' form--error' : '') }) -%}
25+
{%- set widget_attr = {} -%}
26+
{%- if help is not empty -%}
27+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
28+
{%- endif -%}
29+
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
30+
{{- form_label(form) -}}
31+
{{- form_widget(form, widget_attr) -}}
32+
{{- form_help(form) -}}
33+
{{- form_errors(form) -}}
34+
{%- if delete_button is defined and delete_button -%}
35+
{{- block('collection_delete') -}}
36+
{%- endif -%}
37+
</div>
38+
{%- endblock form_row -%}
39+
40+
{%- block choice_widget_expanded -%}
41+
<div {{ block('widget_container_attributes') }}>
42+
{%- for child in form %}
43+
{{- form_row(child) -}}
44+
{% endfor -%}
45+
</div>
46+
{%- endblock choice_widget_expanded -%}
47+
48+
{%- block checkbox_row -%}
49+
{%- set row_attr = row_attr|merge({ class: 'form checkbox' }) -%}
50+
{%- set widget_attr = {} -%}
51+
{%- if help is not empty -%}
52+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
53+
{%- endif -%}
54+
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
55+
{{- form_widget(form, widget_attr) -}}
56+
{{- form_label(form) -}}
57+
{{- form_help(form) -}}
58+
{{- form_errors(form) -}}
59+
</div>
60+
{%- endblock checkbox_row -%}
61+
62+
{%- block button_row -%}
63+
{{- form_widget(form) -}}
64+
{%- endblock button_row -%}
65+
66+
{%- block button_widget -%}
67+
{%- set attr = attr|merge({ class: attr.class|default('') ~ ' button button--primary' }) -%}
68+
{{- parent() -}}
69+
{%- endblock button_widget -%}
70+
71+
{%- block form_errors -%}
72+
{%- for error in errors -%}
73+
<span class="error">{{ error.message }}</span>
74+
{%- endfor -%}
75+
{%- endblock form_errors -%}
76+
77+
{%- block collection_widget -%}
78+
{%- set attr = attr|merge({ class: attr.class|default('') ~ ' collection' }) -%}
79+
{%- set delete_button = allow_delete ? label_delete : false -%}
80+
{% if prototype is defined and not prototype.rendered %}
81+
{%- set attr = attr|merge({'data-prototype': form_row(prototype, { delete_button: delete_button }) }) -%}
82+
{% endif %}
83+
<div {{ block('widget_container_attributes') }}>
84+
{%- if form is rootform -%}
85+
{{ form_errors(form) }}
86+
{%- endif -%}
87+
{% for child in form|filter(child => not child.rendered) %}
88+
{{- form_row(child, { delete_button: delete_button }) -}}
89+
{% endfor %}
90+
{{- form_rest(form) -}}
91+
</div>
92+
{%- if allow_add -%}
93+
<button type="button" class="button button--neutral collection-add" data-collection-add="{{ id }}">
94+
{{ label_add|trans({}, translation_domain) }}
95+
</button>
96+
{%- endif -%}
97+
{%- endblock collection_widget -%}
98+
99+
{%- block collection_delete -%}
100+
<button type="button" class="collection-delete tooltip tooltip--top" data-collection-delete="{{ id }}" data-tooltip="{{ delete_button|trans({}, translation_domain) }}">
101+
<span class="icon-cross"></span>
102+
</button>
103+
{%- endblock -%}
104+
105+
{# Choices.js #}
106+
107+
{%- block choices_row -%}
108+
{%- set widget_attr = {} -%}
109+
{%- if help is not empty -%}
110+
{%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%}
111+
{%- endif -%}
112+
<div{% with {attr: row_attr} %}{{ block('attributes') }}{% endwith %}>
113+
{{- form_label(form) -}}
114+
{{- form_errors(form) -}}
115+
{{- form_widget(form, widget_attr) -}}
116+
{{- form_help(form) -}}
117+
</div>
118+
{%- endblock choices_row -%}
119+
120+
{%- block choices_widget -%}
121+
{%- set type = type|default('text') -%}
122+
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
123+
{%- endblock choices_widget -%}

0 commit comments

Comments
 (0)