{% set container_style = schema.get('style') %}
<div class="row" style="padding-right:0.75em">
  {% include "objects/property_label.html" %}
  {% set is_required = True %}
</div>
<div {% if get_style_variant(schema.style, template_mode) == "full_width_table" %}class="full-width-table-wrapper"{% else %}style="padding-left:2.5em;"{% endif %}>
  <input type="hidden" name="{{ id_prefix }}_hidden" value="array" />
  {% if data is not none %}
    {% for item in data %}
      <input type="hidden" name="{{ id_prefix }}_{{ loop.index0 }}__hidden" value="{{ schema['items']['type'] }}" />
    {% endfor %}
  {% endif %}
  {% if schema['items']['type'] == 'object' %}
    <table class="table">
      <thead>
        <tr>
          {% set item_property_names = get_property_names_in_order(schema["items"]) %}
          {% for property_name in item_property_names %}
            {% set schema = schema["items"].properties[property_name] %}
            {% set property_path = property_path + ('?', property_name) %}
            <th scope="col">
              {% include "objects/table_property_label.html" %}
            </th>
          {% endfor %}
        </tr>
      </thead>
      <tbody>
        {% if data is not none %}
          {% for item in data %}
            {% set schema = schema['items'] %}
            {% set property_path = property_path + (loop.index0,) %}
            {% set id_prefix = id_prefix_for_property_path(property_path, id_prefix_root) %}
            {% set entry_index = loop.index0 %}
            {% set data = item %}
            <tr>
              {% for property_name in item_property_names %}
                <td>
                  {% set is_required = property_name in schema.get('required', ()) %}
                  {% set schema = schema.properties[property_name] %}
                  {% set property_path = property_path + (property_name,) %}
                  {% set id_prefix = id_prefix_for_property_path(property_path, id_prefix_root) %}
                  {% if data is not none and property_name in data %}
                    {% set data = data[property_name] %}
                  {% else %}
                    {% set data = none %}
                  {% endif %}
                  {% if 'conditions' in schema %}
                    <div data-condition-wrapper-for="{{ id_prefix }}" class="condition-wrapper">
                      {% include "objects/inline_edit/inline_edit_any.html" %}
                      <input type="hidden" class="condition-wrapper" data-id-prefix="{{ id_prefix}}" data-conditions='{{ schema["conditions"] | encode_choices | stringify }}'>
                    </div>
                    <div data-condition-replacement-for="{{ id_prefix }}" class="condition-replacement">
                      &mdash;
                    </div>
                  {% else %}
                    {% include "objects/inline_edit/inline_edit_any.html" %}
                  {% endif %}
                </td>
              {% endfor %}
            </tr>
          {% endfor %}
        {% endif %}
      </tbody>
      <tfoot>
        <tr>
          {% for property_name in item_property_names %}
            <th scope="col"></th>
          {% endfor %}
        </tr>
      </tfoot>
    </table>
  {% elif schema['items']['type'] == 'array' %}
    {% set max_used_fields = 0 %}
    {% if data is not none %}
      {% set max_used_fields = [0] %}
      {% for item in data %}
        {% if (item | length) > max_used_fields[-1] %}
          {% set tmp = max_used_fields.append(item | length) %}
        {% endif %}
      {% endfor %}
      {% set max_used_fields = max_used_fields [-1] %}
    {% endif %}
    {% if max_used_fields > 0 %}
      <table class="table">
        <thead>
          <tr>
            {% for i in range(max_used_fields) %}
              <th>{{ _('Field %(index)s', index=i + 1) }}</th>
            {% endfor %}
          </tr>
        </thead>
        <tbody>
          {% for item in data %}
            {% set item_index = loop.index0 %}
            <tr>
              {% for field_index, field in zip_longest(range(max_used_fields), item) %}
                <td>
                  {% set schema = schema["items"]["items"] %}
                  {% set property_path = property_path + (item_index, field_index) %}
                  {% set id_prefix = id_prefix_for_property_path(property_path, id_prefix_root) %}
                  {% set data = field %}
                  {% include "objects/inline_edit/inline_edit_any.html" %}
                </td>
              {% endfor %}
            </tr>
          {% endfor %}
        </tbody>
        <tfoot>
          <tr>
            {% for i in range(max_used_fields) %}
              <th>{{ _('Field %(index)s', index=i + 1) }}</th>
            {% endfor %}
          </tr>
        </tfoot>
      </table>
    {% endif %}
  {% endif %}
</div>
