{% comment %} Stacked Form Layout =================== Renders form fields in a vertical stacked layout (default form layout). Purpose: Provides a standard vertical form layout where each field takes full width with labels above inputs. Usage Examples: Basic form: {% include 'forms/layouts/stacked.html' with form=form %} With fieldsets: {% include 'forms/layouts/stacked.html' with form=form show_fieldsets=True %} Exclude fields: {% include 'forms/layouts/stacked.html' with form=form exclude='password2' %} Parameters: Required: - form: Django form object Optional: - exclude: Comma-separated field names to exclude - fields: Comma-separated field names to include (if set, only these are shown) - show_fieldsets: Group fields by fieldset (default: False) - show_help: Show help text (default: True) - show_required: Show required indicator (default: True) - submit_text: Submit button text (default: 'Submit') - submit_class: Submit button CSS class (default: 'btn-primary') - show_cancel: Show cancel button (default: False) - cancel_url: URL for cancel button - cancel_text: Cancel button text (default: 'Cancel') - form_class: Additional CSS classes for form wrapper Dependencies: - forms/partials/form_field.html - forms/partials/field_error.html - Tailwind CSS Accessibility: - Uses fieldset/legend for grouped fields - Labels properly associated with inputs - Error summary at top for screen readers {% endcomment %} {% load common_filters %} {% with show_help=show_help|default:True show_required=show_required|default:True submit_text=submit_text|default:'Submit' %}
{# Non-field errors at top #} {% if form.non_field_errors %} {% endif %} {# Form fields #} {% for field in form %} {% if field.is_hidden %} {{ field }} {% elif fields %} {# Only show specified fields #} {% if field.name in fields %} {% include 'forms/partials/form_field.html' with field=field show_help=show_help required_indicator=show_required %} {% endif %} {% elif exclude %} {# Exclude specified fields #} {% if field.name not in exclude %} {% include 'forms/partials/form_field.html' with field=field show_help=show_help required_indicator=show_required %} {% endif %} {% else %} {% include 'forms/partials/form_field.html' with field=field show_help=show_help required_indicator=show_required %} {% endif %} {% endfor %} {# Form actions #} {% if show_actions|default:True %}
{% if show_cancel and cancel_url %} {{ cancel_text|default:'Cancel' }} {% endif %}
{% endif %}
{% endwith %}