{% block form_row %}
{% spaceless %}
    <div class="form-group">
        {{ form_label(form) }}
        {{ form_errors(form) }}
        {{ form_widget(form) }}
    </div>
{% endspaceless %}
{% endblock form_row %}

{% block textarea_widget %}
{% set attr = attr|merge({'class' : attr['class']|default('form-control')}) %}
{% spaceless %}
    <textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{% endspaceless %}
{% endblock textarea_widget %}

{% block form_widget_simple %}
{% set attr = attr|merge({'class' : attr['class']|default('form-control')}) %}
{% spaceless %}
    {% set type = type|default('text') %}
    <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% endspaceless %}
{% endblock form_widget_simple %}

{% block checkbox_widget %}
{% set attr = attr|merge({'class' : attr['class']|default('checkbox')}) %}
{% spaceless %}
    <label  for="{{ id }}" class="checkbox"><input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />{{ label|trans }}</label>
{% endspaceless %}
{% endblock checkbox_widget %}

{% block radio_widget -%}
{% set attr = attr|merge({'class' : attr['class']|default('radio')}) %}
{% spaceless %}
    <label  for="{{ id }}" class="radio"><input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />{{ label|trans }}</label>
{% endspaceless %}
{%- endblock radio_widget %}

{% block choice_widget_collapsed %}
{% set attr = attr|merge({'class' : attr['class']|default('form-control input-sm')}) %}
{% spaceless %}
    {% if required and empty_value is none and not empty_value_in_choices and not multiple %}
        {% set required = false %}
    {% endif %}
    <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
        {% if empty_value is not none %}
            <option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
        {% endif %}
        {% if preferred_choices|length > 0 %}
            {% set options = preferred_choices %}
            {{ block('choice_widget_options') }}
            {% if choices|length > 0 and separator is not none %}
                <option disabled="disabled">{{ separator }}</option>
            {% endif %}
        {% endif %}
        {% set options = choices %}
        {{ block('choice_widget_options') }}
    </select>
{% endspaceless %}
{% endblock choice_widget_collapsed %}

{% block choice_widget_expanded -%}
{% set attr = attr|merge({'class' : attr['class']|default('controls')}) %}
    <div {{ block('widget_container_attributes') }}>
    {%- for child in form %}
        {{- form_widget(child) -}}
    {% endfor -%}
    </div>
{% endblock choice_widget_expanded %}

{% block button_attributes %}
{% set attr = attr|merge({'class' : attr['class']|default('btn btn-warning')}) %}
{% spaceless %}
    id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%}
    {%- for attrname, attrvalue in attr -%}
        {{- " " -}}
        {%- if attrname in ['placeholder', 'title'] -%}
            {{- attrname }}="{{ attrvalue|trans({}, translation_domain) }}"
        {%- elseif attrvalue is same as(true) -%}
            {{- attrname }}="{{ attrname }}"
        {%- elseif attrvalue is not same as(false) -%}
            {{- attrname }}="{{ attrvalue }}"
        {%- endif -%}
    {%- endfor -%}
{% endspaceless %}
{% endblock button_attributes %}

{% block form_errors %}
    {% spaceless %}
        {% if errors|length > 0 %}
        <ul>
            {% for error in errors %}
                <li>{{ error.message|split('##')|last }}</li>
            {% endfor %}
        </ul>
        {% endif %}
    {% endspaceless %}
{% endblock form_errors %}

{% block datetime_widget %}
    {% spaceless %}
        {% if widget == 'single_text' %}1
            {{ block('field_widget') }}
        {% else %}
            <div {{ block('widget_container_attributes') }}>
                {{ form_errors(form.date.year) }}
                {{ form_errors(form.date.month) }}
                {{ form_errors(form.date.day) }}
                {{ form_errors(form.time) }}
                <div class="row">
                    <div class="col-lg-2 form-group">{{ form_widget(form.date.year) }}</div>
                    <div class="col-lg-2 form-group">{{ form_widget(form.date.month) }}</div>
                    <div class="col-lg-2 form-group">{{ form_widget(form.date.day) }}</div>
                    <div class="col-lg-1 form-group">{{ form_widget(form.time.hour, { 'attr': { 'size': '1' } }) }}</div>
                    <div class="col-lg-1 form-group">{{ form_widget(form.time.minute, { 'attr': { 'size': '1' } }) }}</div>
                </div>

            </div>
        {% endif %}
    {% endspaceless %}
{% endblock datetime_widget %}

{% block date_widget %}
    {% spaceless %}
        {% if widget == 'single_text' %}
            {{ block('field_widget') }}
        {% else %}
            {{ date_pattern|replace({
                '{{ year }}':  form_widget(form.year),
                '{{ month }}': form_widget(form.month),
                '{{ day }}':   form_widget(form.day),
            })|raw }}
        {% endif %}
    {% endspaceless %}
{% endblock date_widget %}

{% block time_widget %}
    {% spaceless %}
        {% if widget == 'single_text' %}
            {{ block('field_widget') }}
        {% else %}
            {{ form_widget(form.hour, { 'attr': { 'size': '1' } }) }}:{{ form_widget(form.minute, { 'attr': { 'size': '1' } }) }}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1' } }) }}{% endif %}
        {% endif %}
    {% endspaceless %}
{% endblock time_widget %}