{# Widget attributes #} {% block widget_container_attributes %} {% apply spaceless %} {% if id is not empty %}id="{{ id }}" {% endif %} {% for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} {% endapply %} {% endblock widget_container_attributes %} {# Form row #} {% block form_row %} {% apply spaceless %}
{{ form_label(form) }} {{ form_widget(form) }} {{ form_errors(form) }}
{% endapply %} {% endblock form_row %} {# Form label #} {% block form_label %} {% apply spaceless %} {% if label is not same as(false) %} {% if not compound %} {% set label_attr = label_attr|merge({'for': id}) %} {% endif %} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' form-control-label')|trim}) %} {% if required %} {% set label_attr = label_attr|merge({'class': label_attr.class ~ ' form-control-label--required'}) %} {% endif %} {% if label is empty %} {% set label = name|humanize %} {% endif %} {{ label|trans({}, translation_domain) }}{% if required %} *{% endif %} {% endif %} {% endapply %} {% endblock form_label %} {# Form widget: Hidden #} {% block hidden_widget %} {% apply spaceless %} {% endapply %} {% endblock hidden_widget %} {# Form widget: Input #} {% block form_widget_simple %} {% apply spaceless %} {% set type = type|default('text') %} {% set class = (attr.class|default('') ~ ' form-control form-control--input') %} {% set attr = attr|merge({'class': class|trim}) %} {% endapply %} {% endblock form_widget_simple %} {# Form widget: Textarea #} {% block textarea_widget %} {% apply spaceless %} {% set class = (attr.class|default('') ~ ' form-control form-control--textarea form-widget--textarea') %} {% set attr = attr|merge({'class': class|trim}) %} {% endapply %} {% endblock textarea_widget %} {# Form widget: Selectbox #} {% block choice_widget_collapsed %} {% apply spaceless %}
{% set class = (attr.class|default('') ~ ' form-control form-control--select') %} {% set attr = attr|merge({'class': class|trim}) %}
{% endapply %} {% endblock choice_widget_collapsed %} {# Form widget: Choice expanded - Radiobutton / Checkbox #} {% block choice_widget_expanded %} {% apply spaceless %}
{% for child in form %} {{ form_widget(child, { 'required': false }) }} {% endfor %}
{% endapply %} {% endblock choice_widget_expanded %} {# Form widget: Radiobutton #} {% block radio_widget %} {% apply spaceless %}
{% if required and not compound %} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} {% endif %} {% if label is empty %} {% set label = name|humanize %} {% endif %} {% set class = (attr.class|default('') ~ ' form-control-choice') %} {% set attr = attr|merge({'class': class|trim}) %}
{% endapply %} {% endblock radio_widget %} {# Form widget: Checkbox #} {% block checkbox_widget %} {% apply spaceless %}
{% if required %} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} {% endif %} {% if label is empty %} {% set label = name|humanize %} {% endif %} {% set class = (attr.class|default('') ~ ' form-control-choice') %} {% set attr = attr|merge({'class': class|trim}) %}
{% endapply %} {% endblock checkbox_widget %} {# Form widget: File upload #} {% block file_widget %} {% apply spaceless %}
{{ block('form_widget') }}
{% endapply %} {% endblock %} {# Form errors #} {% block form_errors %} {% apply spaceless %} {% if errors|length > 0 %} {% for error in errors %} {{ error.message }} {% endfor %} {% endif %} {% endapply %} {% endblock form_errors %} {# Button row #} {% block button_row %} {% apply spaceless %}
{{ form_widget(form) }}
{% endapply %} {% endblock button_row %} {# Submit button #} {% block submit_widget %} {% apply spaceless %}
{% set type = type|default('submit') %} {{ block('button_widget') }}
{% endapply %} {% endblock submit_widget %}