{% extends 'base.html' %} {% block title %}Edit Absence | FoxFitt{% endblock %} {% block content %} {% comment %} === EDIT ABSENCE PAGE === Single form for editing one Absence row. The is_paid checkbox is the magic field — toggling it on creates a Bonus PayrollAdjustment at the worker's daily rate; toggling it off deletes the adjustment (UNLESS it's already been paid, in which case the view surfaces an error). Why two forms? HTML doesn't allow nested
tags. The delete action needs its own form to POST to /absences//delete/. So the delete form lives OUTSIDE the edit form (hidden), and the Delete button inside the edit form uses the HTML5 `form="..."` attribute to submit the delete form instead of its parent edit form. {% endcomment %}

Edit Absence

{% if messages %} {% for m in messages %}
{{ m }}
{% endfor %} {% endif %} {% comment %} Hidden sibling form so the Delete button can submit to its own URL. Hidden via inline style — only the button inside the edit form is visible. {% endcomment %} {% csrf_token %}
{% csrf_token %}
{{ form.worker }} {{ form.worker.errors }}
{{ form.date }} {{ form.date.errors }}
{{ form.project }} {{ form.project.errors }} Which project was the worker absent from?
{{ form.reason }} {{ form.reason.errors }}
{{ form.is_paid }}
{{ form.notes }} {{ form.notes.errors }}
{% if form.non_field_errors %}
{{ form.non_field_errors }}
{% endif %}
{% comment %} `form="absence-delete-form"` makes this button submit the hidden delete form rather than its enclosing edit form. {% endcomment %}
Cancel
{% endblock %}