{% extends "form_div_layout.html.twig" %} {# Based on Foundation 5 Doc #} {# Widgets #} {% block form_widget_simple -%} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {{- parent() -}} {%- endblock form_widget_simple %} {% block textarea_widget -%} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {{- parent() -}} {%- endblock textarea_widget %} {% block button_widget -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' button')|trim}) %} {{- parent() -}} {%- endblock button_widget %} {% block money_widget -%}
{% set prepend = '{{' == money_pattern[0:2] %} {% if not prepend %}
{{ money_pattern|form_encode_currency }}
{% endif %}
{{- block('form_widget_simple') -}}
{% if prepend %}
{{ money_pattern|form_encode_currency }}
{% endif %}
{%- endblock money_widget %} {% block percent_widget -%}
{%- if symbol -%}
{{- block('form_widget_simple') -}}
{{ symbol|default('%') }}
{%- else -%}
{{- block('form_widget_simple') -}}
{%- endif -%}
{%- endblock percent_widget %} {% block datetime_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %}
{{ form_errors(form.date) }}
{{ form_errors(form.time) }}
{{ form_widget(form.date, { datetime: true } ) }}
{{ form_widget(form.time, { datetime: true } ) }}
{% endif %} {%- endblock datetime_widget %} {% block date_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %} {% if datetime is not defined or not datetime %}
{% endif %} {{- date_pattern|replace({ '{{ year }}': '
' ~ form_widget(form.year) ~ '
', '{{ month }}': '
' ~ form_widget(form.month) ~ '
', '{{ day }}': '
' ~ form_widget(form.day) ~ '
', })|raw -}} {% if datetime is not defined or not datetime %}
{% endif %} {% endif %} {%- endblock date_widget %} {% block time_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' row')|trim}) %} {% if datetime is not defined or false == datetime %}
{% endif %} {% if with_seconds %}
{{ form_widget(form.hour) }}
:
{{ form_widget(form.minute) }}
:
{{ form_widget(form.second) }}
{% else %}
{{ form_widget(form.hour) }}
:
{{ form_widget(form.minute) }}
{% endif %} {% if datetime is not defined or false == datetime %}
{% endif %} {% endif %} {%- endblock time_widget %} {% block choice_widget_collapsed -%} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {% if multiple -%} {% set attr = attr|merge({style: (attr.style|default('') ~ ' height: auto; background-image: none;')|trim}) %} {% endif %} {% if required and placeholder is none and not placeholder_in_choices and not multiple -%} {% set required = false %} {%- endif -%} {%- endblock choice_widget_collapsed %} {% block choice_widget_expanded -%} {% if '-inline' in label_attr.class|default('') %} {% else %}
{% for child in form %} {{ form_widget(child, { parent_label_class: label_attr.class|default(''), }) }} {% endfor %}
{% endif %} {%- endblock choice_widget_expanded %} {% block checkbox_widget -%} {% set parent_label_class = parent_label_class|default('') %} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %} {% if 'checkbox-inline' in parent_label_class %} {{ form_label(form, null, { widget: parent() }) }} {% else %}
{{ form_label(form, null, { widget: parent() }) }}
{% endif %} {%- endblock checkbox_widget %} {% block radio_widget -%} {% set parent_label_class = parent_label_class|default('') %} {% if 'radio-inline' in parent_label_class %} {{ form_label(form, null, { widget: parent() }) }} {% else %} {% if errors|length > 0 -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' error')|trim}) %} {% endif %}
{{ form_label(form, null, { widget: parent() }) }}
{% endif %} {%- endblock radio_widget %} {# Labels #} {% block form_label -%} {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} {{- parent() -}} {%- endblock form_label %} {% block choice_label -%} {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} {% set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) %} {{- block('form_label') -}} {%- endblock choice_label %} {% block checkbox_label -%} {{- block('checkbox_radio_label') -}} {%- endblock checkbox_label %} {% block radio_label -%} {{- block('checkbox_radio_label') -}} {%- endblock radio_label %} {% block checkbox_radio_label -%} {% if required %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} {% endif %} {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} {% if parent_label_class is defined %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ parent_label_class)|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 %} {{ widget|raw }} {{ translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }} {%- endblock checkbox_radio_label %} {# Rows #} {% block form_row -%} {%- set widget_attr = {} -%} {%- if help is not empty -%} {%- set widget_attr = {attr: {'aria-describedby': id ~"_help"}} -%} {%- endif -%}
{{- form_label(form) -}} {{- form_widget(form, widget_attr) -}} {{- form_help(form) -}} {{- form_errors(form) -}}
{%- endblock form_row %} {% block choice_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock choice_row %} {% block date_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock date_row %} {% block time_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock time_row %} {% block datetime_row -%} {% set force_error = true %} {{ block('form_row') }} {%- endblock datetime_row %} {% block checkbox_row -%}
{{ form_widget(form) }} {{- form_help(form) -}} {{ form_errors(form) }}
{%- endblock checkbox_row %} {% block radio_row -%}
{{ form_widget(form) }} {{- form_help(form) -}} {{ form_errors(form) }}
{%- endblock radio_row %} {# Errors #} {% block form_errors -%} {% if errors|length > 0 -%} {% if form is not rootform %}{% else %}
{% endif %} {%- for error in errors -%} {{ error.message }} {% if not loop.last %}, {% endif %} {%- endfor -%} {% if form is not rootform %}{% else %}
{% endif %} {%- endif %} {%- endblock form_errors %}