{% use "bootstrap_base_layout.html.twig" %} {# Widgets #} {% block money_widget -%} {%- set prepend = not (money_pattern starts with '{{') -%} {%- set append = not (money_pattern ends with '}}') -%} {%- if prepend or append -%}
{%- if prepend -%}
{{ money_pattern|form_encode_currency }}
{%- endif -%} {{- block('form_widget_simple') -}} {%- if append -%}
{{ money_pattern|form_encode_currency }}
{%- endif -%}
{%- else -%} {{- block('form_widget_simple') -}} {%- endif -%} {%- endblock money_widget %} {% block datetime_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {{- parent() -}} {%- endblock datetime_widget %} {% block date_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {{- parent() -}} {%- endblock date_widget %} {% block time_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {{- parent() -}} {%- endblock time_widget %} {% block dateinterval_widget -%} {%- if widget != 'single_text' and not valid -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control is-invalid')|trim}) -%} {% set valid = true %} {%- endif -%} {%- if widget == 'single_text' -%} {{- block('form_widget_simple') -}} {%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
{%- if with_years -%}
{{ form_label(form.years) }} {{ form_widget(form.years) }}
{%- endif -%} {%- if with_months -%}
{{ form_label(form.months) }} {{ form_widget(form.months) }}
{%- endif -%} {%- if with_weeks -%}
{{ form_label(form.weeks) }} {{ form_widget(form.weeks) }}
{%- endif -%} {%- if with_days -%}
{{ form_label(form.days) }} {{ form_widget(form.days) }}
{%- endif -%} {%- if with_hours -%}
{{ form_label(form.hours) }} {{ form_widget(form.hours) }}
{%- endif -%} {%- if with_minutes -%}
{{ form_label(form.minutes) }} {{ form_widget(form.minutes) }}
{%- endif -%} {%- if with_seconds -%}
{{ form_label(form.seconds) }} {{ form_widget(form.seconds) }}
{%- endif -%} {%- if with_invert %}{{ form_widget(form.invert) }}{% endif -%}
{%- endif -%} {%- endblock dateinterval_widget %} {% block percent_widget -%}
{{- block('form_widget_simple') -}}
%
{%- endblock percent_widget %} {% block file_widget -%} <{{ element|default('div') }} class="custom-file"> {%- set type = type|default('file') -%} {{- block('form_widget_simple') -}} {% endblock %} {% block form_widget_simple -%} {% if type is not defined or type != 'hidden' %} {%- set attr = attr|merge({class: (attr.class|default('') ~ (type|default('') == 'file' ? ' custom-file-input' : ' form-control'))|trim}) -%} {% endif %} {%- if type is defined and (type == 'range' or type == 'color') %} {# Attribute "required" is not supported #} {%- set required = false -%} {% endif %} {{- parent() -}} {%- endblock form_widget_simple %} {%- block widget_attributes -%} {%- if not valid %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' is-invalid')|trim}) %} {% endif -%} {{ parent() }} {%- endblock widget_attributes -%} {% block button_widget -%} {%- set attr = attr|merge({class: (attr.class|default('btn-secondary') ~ ' btn')|trim}) -%} {{- parent() -}} {%- endblock button_widget %} {% block submit_widget -%} {%- set attr = attr|merge({class: (attr.class|default('btn-primary'))|trim}) -%} {{- parent() -}} {%- endblock submit_widget %} {% block checkbox_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {%- if 'checkbox-custom' in parent_label_class -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
{{- form_label(form, null, { widget: parent() }) -}}
{%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%}
{{- form_label(form, null, { widget: parent() }) -}}
{%- endif -%} {%- endblock checkbox_widget %} {% block radio_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%} {%- if 'radio-custom' in parent_label_class -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' custom-control-input')|trim}) -%}
{{- form_label(form, null, { widget: parent() }) -}}
{%- else -%} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-check-input')|trim}) -%}
{{- form_label(form, null, { widget: parent() }) -}}
{%- endif -%} {%- endblock radio_widget %} {% block choice_widget_expanded -%}
{%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, valid: valid, }) -}} {% endfor -%}
{%- endblock choice_widget_expanded %} {# Labels #} {% block form_label -%} {% if label is not same as(false) -%} {%- if compound is defined and compound -%} {%- set element = 'legend' -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} {%- else -%} {%- set label_attr = label_attr|merge({for: id}) -%} {%- endif -%} {% if required -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} {%- endif -%} {% if label is empty -%} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {%- endif -%} <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}{% block form_label_errors %}{{- form_errors(form) -}}{% endblock form_label_errors %} {%- else -%} {%- if errors|length > 0 -%}
{{- form_errors(form) -}}
{%- endif -%} {%- endif -%} {%- endblock form_label %} {% block checkbox_radio_label -%} {#- Do not display the label if widget is not defined in order to prevent double label rendering -#} {%- if widget is defined -%} {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class) %} {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class) %} {%- if is_parent_custom or is_custom -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' custom-control-label')|trim}) -%} {%- else %} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' form-check-label')|trim}) -%} {%- endif %} {%- if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} {%- endif -%} {%- 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)|replace({'checkbox-inline': '', 'radio-inline': '', 'checkbox-custom': '', 'radio-custom': ''})|trim}) -%} {%- endif -%} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ '%name%': name, '%id%': id, }) -%} {%- else -%} {%- set label = name|humanize -%} {%- endif -%} {%- endif -%} {{ widget|raw }} {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}} {{- form_errors(form) -}} {%- endif -%} {%- endblock checkbox_radio_label %} {# Rows #} {% block form_row -%} {%- if compound is defined and compound -%} {%- set element = 'fieldset' -%} {%- endif -%} {%- set widget_attr = {} -%} {%- if help is not empty -%} {%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} {%- endif -%} <{{ element|default('div') }} class="form-group"> {{- form_label(form) -}} {{- form_widget(form, widget_attr) -}} {{- form_help(form) -}} {%- endblock form_row %} {# Errors #} {% block form_errors -%} {%- if errors|length > 0 -%} {%- for error in errors -%} {{ 'Error'|trans({}, 'validators') }} {{ error.message }} {%- endfor -%} {%- endif %} {%- endblock form_errors %} {# Help #} {% block form_help -%} {%- if help is not empty -%} {%- set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' form-text text-muted')|trim}) -%} {%- if translation_domain is same as(false) -%} {{- help -}} {%- else -%} {{- help|trans({}, translation_domain) -}} {%- endif -%} {%- endif -%} {%- endblock form_help %}