{% extends "adminsite/base.html" %} {% import "adminsite/_icons.html" as icons %} {% import "adminsite/_form_layout.html" as layout_of with context %} {#- Every problem in one place at the top, each a link to its field, so a mistake at the bottom of a long form is never missed. -#} {%- set problems = [] -%} {%- for row in rows -%} {%- for problem in row.problems -%} {%- set ignored = problems.append(problem) -%} {%- endfor -%} {%- endfor -%} {%- for table in inlines -%} {%- for item in table.rows -%} {%- set number = loop.index -%} {%- for cell in item.cells if cell.error -%} {%- set ignored = problems.append(("field-" ~ cell.path, _("{thing}, row {number}, {field}", thing=table.label, number=number, field=cell.label|in_sentence), cell.error)) -%} {%- endfor -%} {%- endfor -%} {%- endfor -%} {#- The title says so first, so a screen reader hears it as the page loads. -#} {% block page_title %}{% if form_error or problems %}{{ _('Error:') }} {% endif %}{{ heading }} ยท {{ title }}{% endblock %} {% block breadcrumb %} {% endblock %} {% block header_class %}border-b border-base-300 lg:pt-2 lg:pb-5{% endblock %} {% block header %}

{{ _('Edit {name}', name=heading) if record is not none else heading }}

{% endblock %} {% block content %}
{#- novalidate: the browser's own checks speak its language and look like nothing else here, so every mistake is told by the admin instead. -#}
{{ csrf_input | safe if csrf_input }} {% if form_error or problems %} {% endif %} {#- A card for each panel and each set of tabs the view's layout has, and one for each run of fields outside them: with no layout, one card of every field, one to a line, in the order of the view's fields. -#} {% set by_path = {} %} {% for one in rows %}{% set ignored = by_path.update({one.path: one}) %}{% endfor %} {#- A field with a mistake, its own or one inside the document it holds. -#} {% set wrong = rows|selectattr("problems")|map(attribute="path")|list %} {% for card in layout %} {% if card.kind == "panel" and card.collapsible %} {#- Open where it holds a mistake, so the mistake is never folded away. -#}
{{ card.title }} {% if card.description %}{{ card.description }}{% endif %} {{ icons.icon("chevron-right", 16) }}
{% for piece in card.children %}{{ layout_of.part(piece, by_path, wrong) }}{% endfor %}
{% elif card.kind == "panel" %}

{{ card.title }}

{% if card.description %}

{{ card.description }}

{% endif %}
{% for piece in card.children %}{{ layout_of.part(piece, by_path, wrong) }}{% endfor %}
{% elif card.kind == "tabs" %}
{{ layout_of.part(card, by_path, wrong) }}
{% else %}
{% if loop.first %}

{{ view.label }}

{% endif %}
{% for piece in card.children %}{{ layout_of.part(piece, by_path, wrong) }}{% endfor %}
{% endif %} {% endfor %} {% include "adminsite/_inlines.html" %} {#- The one place to save: it stays at the foot of the screen while a long form scrolls, and sits just under a short one. -#}
{{ _('Cancel') }} {% if can_delete and record is not none %} {% endif %}
{% if can_delete and record is not none %} {% endif %} {% endblock %}