{% extends "flask_deck/base.html" %} {% block breadcrumbs %} / {{ view.plural_label }} / {{ "New " ~ view.label if mode == 'create' else "Edit #" ~ pk_str }} {% endblock %} {% block content %}

{{ "Create " ~ view.label if mode == 'create' else "Edit " ~ view.label }}

All mutations are CSRF-protected and recorded to the Audit Ledger.

{{ deck_icon("arrow-left", 13) }} {{ _("Back") }} {% if view_on_site_url %} {{ deck_icon("external-link", 13) }} View on Site {% endif %} {% if mode == 'edit' and can_view_audit %} {{ deck_icon("git-compare", 13) }} {{ _("History") }} {% endif %}
{% macro render_form_field(spec, errors) %} {% set wtype = spec.widget %}
{% if spec.kind == 'display_ro' %}
{{ spec.formatted_html }}
{% elif spec.custom_widget_html is not none %} {{ spec.custom_widget_html }} {% elif spec.kind == 'file' %}
{% if spec.media_url and spec.file_kind == 'image' %} {% elif spec.media_url %} {{ deck_icon("paperclip", 12) }} {{ spec.value.rsplit('/', 1)[-1] }} {% endif %} {% if spec.value %}{{ spec.value.rsplit('/', 1)[-1] }}{% else %}Drop {{ spec.file_kind or 'file' }} here or browse…{% endif %}
{% if spec.value and not spec.required and not spec.readonly %} {% endif %}
{% elif spec.kind == 'array' %}
{% elif spec.kind == 'boolean' %} {% elif spec.kind == 'enum' and spec.radio_layout in ['horizontal', 'vertical'] %}
{% if not spec.required %} {% endif %} {% for val, lbl in spec.choices %} {% endfor %}
{% elif spec.kind == 'enum' and wtype == 'segmented' %}
{% for val, lbl in spec.choices %} {% endfor %}
{% elif spec.kind == 'enum' %} {% elif spec.kind == 'fk' and spec.radio_layout in ['horizontal', 'vertical'] %}
{% if not spec.required %} {% endif %} {% for opt in spec.fk_options %} {% endfor %}
{% elif spec.kind == 'fk' %}
{% if spec.fk_target_slug and (spec.fk_can_create or spec.fk_can_edit or spec.fk_can_view or spec.fk_can_delete) %}
{% if spec.fk_lookup_url and spec.fk_can_view and not spec.readonly %} {% endif %} {% if spec.fk_can_create %} {% endif %} {% if spec.fk_can_edit %} {% endif %} {% if spec.fk_can_view %} {% endif %} {% if spec.fk_can_delete %} {% endif %}
{% endif %}
{% elif spec.kind == 'm2m' and spec.m2m_mode == 'dual' %}
Available
{% for opt in spec.options %} {% if opt.id not in spec.selected_ids %} {% endif %} {% endfor %}
{% if spec.m2m_can_create and spec.m2m_target_slug %} {% endif %}
Selected ({{ spec.selected_ids | length }})
{% for opt in spec.options %} {% if opt.id in spec.selected_ids %} {% endif %} {% endfor %}
{% for opt in spec.options %} {% if opt.id in spec.selected_ids %} {% endif %} {% endfor %}
{% elif spec.kind == 'm2m' and spec.m2m_mode == 'async' %}
{{ spec.selected_items | length }} selected {% if spec.m2m_can_create and spec.m2m_target_slug %} {% endif %}
{% for it in spec.selected_items %} {{ it.label }} {% if not spec.readonly %}{% endif %} {% endfor %}
{% elif spec.kind == 'm2m' %}
{{ spec.selected_ids | length }} selected {% if spec.m2m_can_create and spec.m2m_target_slug %} {% endif %}
{% for opt in spec.options %} {% else %} No related records available. {% endfor %}
{% elif spec.kind == 'json' and wtype == 'json_kv' %}
{% elif wtype == 'markdown' %}
XSS-safe DOM preview
{% elif wtype == 'slider' and spec.kind in ['integer', 'float'] %}
{{ spec.value or 0 }}%
{% elif spec.kind in ['text', 'json'] %} {% elif spec.kind in ['integer', 'float', 'decimal'] %} {% elif spec.kind == 'date' %}
{% if not spec.readonly %}{% endif %}
{% elif spec.kind == 'time' %}
{% if not spec.readonly %}{% endif %}
{% elif spec.kind == 'datetime' %}
{% if not spec.readonly %}{% endif %}
{% elif spec.kind == 'email' %} {% elif spec.kind == 'url' %} {% else %} {% endif %} {% if spec.help_text %}
{{ spec.help_text }}
{% endif %} {% if errors.get(spec.name) %}
{{ errors[spec.name] | join(' ') }}
{% endif %}
{% endmacro %} {% macro render_inline_control(inline, col, idx_expr, row) %} {% set fname = 'inline__' ~ inline.slug ~ '__' ~ idx_expr ~ '__' ~ col.name %} {% set cur_v = row['values'][col.name] if row else '' %} {% if col.kind == 'display_ro' %}
{{ row.ro_html[col.name] if (row and row.ro_html and col.name in row.ro_html) else '—' }}
{% elif row and row.widget_html and col.name in row.widget_html %} {{ row.widget_html[col.name] }} {% elif not row and col.template_widget_html %} {{ col.template_widget_html }} {% elif col.kind == 'file' %}
{% set im_url = row.media_urls.get(col.name) if (row and row.media_urls) else None %} {% if im_url and col.file_kind == 'image' %} {% elif im_url %} {{ deck_icon("paperclip", 11) }} {{ (cur_v|string).rsplit('/', 1)[-1] }} {% endif %} {% if cur_v and not col.required and not col.readonly %} {% endif %}
{% elif col.kind == 'fk' and col.fk_search_url %}
{% if col.fk_lookup_url and col.fk_can_view %} {% endif %}
{% elif col.kind == 'fk' %} {% elif col.kind == 'enum' %} {% elif col.kind == 'boolean' %} {% elif col.kind == 'date' %} {% elif col.kind == 'datetime' %} {% elif col.kind == 'time' %} {% elif col.kind == 'text' %} {% else %} {% endif %} {% endmacro %}
1 %} data-deck-wizard{% endif %}> {{ render_slot('form_above') }} {% set use_tabs = (view.form_layout == 'tabs' and fieldsets | length > 1) %} {% set use_wizard = (view.form_layout == 'wizard' and fieldsets | length > 1) %} {% if save_on_top and not use_wizard %}
{{ "Create " ~ view.label if mode == 'create' else "Edit " ~ view.label }}
{% if can_add_another %} {% endif %} {% if can_save_as %} {% endif %} {{ _("Cancel") }}
{% endif %} {% if errors.get('__all__') %} {% endif %} {% if occ_conflict %}

3-Way Concurrent Edit Conflict

HTTP 409
{% for row in occ_conflict %} {% endfor %}
Field Your Submitted Value Current Database Value
{{ row.label }} ({{ row.field }}) {{ row.submitted }} {{ row.current }}
{% endif %} {% if requires_approval_hint %}
Four-Eyes Approval Required: Submitting this form validates constraints and queues the mutation in Approvals for peer review instead of writing immediately.
{% endif %} {% if use_tabs %}
{% for fs in fieldsets %} {% endfor %}
{% elif use_wizard %}
{% for fs in fieldsets %} {% endfor %}
{% endif %} {% for fs in fieldsets %} {% if not use_tabs and not use_wizard and fs.collapsible %}

{% if fs.icon %}{{ deck_icon(fs.icon, 14) }} {% endif %}{{ fs.title }}

{% if fs.description %}

{{ fs.description }}

{% endif %}
Click to toggle
{% for row_cols in fs.rows %} {% if row_cols | length > 1 %}
{% for col in row_cols %}{{ render_form_field(field_specs[col], errors) }}{% endfor %}
{% else %} {{ render_form_field(field_specs[row_cols[0]], errors) }} {% endif %} {% endfor %}
{% else %} {% endif %} {% endfor %} {% for inline in inlines %} {% if inline.collapsible %}

{{ inline.label }} {{ inline.rows | length }}

Inline child records saved atomically with parent{% if inline.min_num %} · min {{ inline.min_num }}{% endif %}

Click to toggle
{% if inline.can_create %}
{% endif %} {% else %}

{{ inline.label }}

Inline child records saved atomically with parent{% if inline.min_num %} · min {{ inline.min_num }}{% endif %}

{% if inline.can_create %} {% endif %}
{% endif %} {% set inl_ns = namespace(errs=[]) %} {% for ek, emsgs in errors.items() %} {% if ek == inline.slug or ek.startswith(inline.slug ~ '[') %} {% for m in emsgs %}{% set _ = inl_ns.errs.append(ek ~ ': ' ~ m) %}{% endfor %} {% endif %} {% endfor %} {% if inl_ns.errs %}
{% endif %} {% if inline.layout == 'stacked' %}
{% for row in inline.rows %} {% set idx = loop.index0 %}
{{ inline.label }} #{{ loop.index }}{% if row.pk %} · PK {{ row.pk }}{% endif %}
{% if row.change_url %}{{ deck_icon("external-link", 12) }} Open{% endif %} {% if inline.can_delete %}{% endif %}
{% for col in inline.columns %}
{{ render_inline_control(inline, col, idx, row) }} {% if col.help_text %}
{{ col.help_text }}
{% endif %}
{% endfor %}
{% endfor %}
{% else %}
{% for col in inline.columns %}{% endfor %} {% if inline.can_delete or inline.show_change_link %}{% endif %} {% for row in inline.rows %} {% set idx = loop.index0 %} {% for col in inline.columns %} {% endfor %} {% if inline.can_delete or inline.show_change_link %} {% endif %} {% endfor %}
{{ col.label }}Actions
{% if loop.first %} {% endif %} {{ render_inline_control(inline, col, idx, row) }}
{% if row.change_url %}{{ deck_icon("external-link", 13) }}{% endif %} {% if inline.can_delete %}{% endif %}
{% endif %} {% if inline.collapsible %}
{% else %}{% endif %} {% endfor %} {{ render_slot('form_below') }}
⌘S Save · ⌘⇧S Save & continue
{% if use_wizard %} {% endif %} {% if can_add_another %} {% endif %} {% if can_save_as %} {% endif %} {{ _("Cancel") }}
{% endblock %} {% block extra_scripts %} {% endblock %}