{# Shared form sections for required, optional, and nested fields #} {% if required_fields %}

Required Fields

{% for field in required_fields %} {% include "partials/field.html" %} {% endfor %}
{% endif %} {% if optional_fields %}
Optional Fields{% if optional_fields|length %} ({{ optional_fields|length }}){% endif %}
{% if optional_fields|length > 8 %} {# A wall of dozens of fields is unfindable by eye; filter by name or description. Shown only when the list is long enough to need it. #} {% endif %} {% for field in optional_fields %} {% include "partials/field.html" %} {% endfor %}
{% endif %} {% if is_edit and inline_tables %}

Related Entities

{# Render tables for spec-defined nested fields #} {% for field in nested_fields %} {% set table_data = inline_tables.get(field.name, {}) %} {% set child_type = table_data.nested_entity_type if table_data else field.items %} {% if table_data %} {% include "partials/inline_table.html" with context %} {% else %} {% include "partials/field.html" %} {% endif %} {% endfor %} {# Render tables for reference-linked children (not in nested_fields) #} {% set nested_field_names = nested_fields | map(attribute='name') | list %} {% for field_name, table_data in inline_tables.items() %} {% if field_name not in nested_field_names and table_data.rows %} {% set field = {'name': field_name, 'items': table_data.nested_entity_type} %} {% set child_type = table_data.nested_entity_type %} {% include "partials/inline_table.html" with context %} {% endif %} {% endfor %} {# Add Child Entity buttons for tree-based children #} {% if child_entity_types %}
Add child entity: {% for child_type in child_entity_types %} {% endfor %}
{% endif %}
{% elif nested_fields %}

Related Entities

{% for field in nested_fields %} {% include "partials/field.html" %} {% endfor %}
{% endif %}