{% form_theme form with aa_admin_config.form_themes|default([]) %}

{{ form_start(form) }}
{% set submits = [] %}
{% set images = [] %}
{% set files = [] %}
{% set collections = [] %}
{% set buttonConfigs = [] %}
{% set textareas = [] %}
{% set checkboxs = [] %}
{% set others = [] %}

{% for formChild in form %}
  {% if formChild.vars.name|slice(0, 6) == 'submit' %}
    {% set submits = submits|merge([formChild]) %}
  {% elseif formChild.vars.block_prefixes[3] is defined and formChild.vars.block_prefixes[3] == 'rich_text' %}
    {% set textareas = textareas|merge([formChild]) %}
  {% elseif formChild.vars.block_prefixes[1] == 'checkbox' %}
    {% set checkboxs = checkboxs|merge([formChild]) %}
  {% elseif formChild.vars.block_prefixes[1] == 'aa_image' %}
    {% set images = images|merge([formChild]) %}
  {% elseif formChild.vars.block_prefixes[1] == 'aa_file' %}
    {% set files = files|merge([formChild]) %}
  {% elseif formChild.vars.block_prefixes[1] == 'aa_admin_collection' %}
    {% set collections = collections|merge([formChild]) %}
  {% elseif formChild.vars.block_prefixes[1] == 'simple_button' %}
    {% set buttonConfigs = buttonConfigs|merge([formChild]) %}
  {% else %}
    {% set others = others|merge([formChild]) %}
  {% endif %}
{% endfor %}

{% for formChild in textareas %}
  <div class="col-12">
    {{ form_row(formChild) }}
  </div>
{% endfor %}

{% for formChild in images %}
  <div class="col-12">
    {{ form_row(formChild) }}
  </div>
{% endfor %}

{% for formChild in files %}
  <div class="col-12">
    {{ form_row(formChild) }}
  </div>
{% endfor %}

{% for formChild in collections %}
  <div class="col-12">
    {{ form_row(formChild) }}
  </div>
{% endfor %}

{% for formChild in buttonConfigs %}
  <div class="col-12">
    {{ form_row(formChild) }}
  </div>
{% endfor %}

<div class="d-flex flex-wrap">
  {% for formChild in others %}
    <div class="col-6">
      {{ form_row(formChild) }}
    </div>
  {% endfor %}
</div>

{% for formChild in checkboxs %}
  <div class="col-12">
    {{ form_row(formChild) }}
  </div>
{% endfor %}

<hr>

<div class="form-group submit-actions d-inline-flex">
  <div class="btn-group">
    {% for submit in submits %}
      {{ form_widget(submit) }}
    {% endfor %}
  </div>
</div>

{{ form_end(form) }}
