Skip to content

Forms learn to retire - #33

Merged
AllTerrainDeveloper merged 1 commit into
mainfrom
feature/archive-forms
Aug 21, 2026
Merged

AllTerrainDeveloper merged 1 commit into
mainfrom
feature/archive-forms

Conversation

@AllTerrainDeveloper

Copy link
Copy Markdown
Owner

An Archive button that moves the form and everything that belongs to it — entries and stats — out of every list in one move, and an Unarchive that puts every one of them back exactly as it was.

The model

  • The form takes a real registered post status, atf-archived. Nothing is copied anywhere; meta, revisions and trash behaviour all keep working.
  • Its previous status is remembered (_atf_prearchive_status), so unarchiving restores what was true — a draft comes back a draft, never surprise-published.
  • Its entries stay in place and keep their own statuses (unread/read/spam are facts about the entry the trip must not erase) and take an _atf_archived marker instead. Every surface that reaches entries through a form picker is covered the moment the form leaves the pickers; the marker covers the two that don't — the all-forms entry list and the all-forms export, which atf_query_entries() now filters.
  • Its stats are meta on the form, so they need no moving: they vanish with it and return with it, untouched.
  • atf_form_availability() reports an archived form closed with reason archived — checked before the editor bypass, because the way past the archive is unarchiving. It neither renders (closed notice, no <form>) nor accepts submissions.

Where it lives

  • Archive: the form's Settings tab — explanation, confirm dialog with the entry count, unsaved edits saved first.
  • Restore: the "Start a new form" dialog gains "Or bring one back from the archive" — restoring a retired form is a way of getting a form. Each row shows what it holds (entries · submissions · views); Restore reopens it in the builder.
  • REST: POST /forms/{id}/archive, POST /forms/{id}/unarchive, GET /forms?archived=1 (same summary shape, same capability). New actions atf_form_archived / atf_form_unarchived, documented in hooks-reference.md.
  • Entries and analytics windows need no changes — their pickers read the active list.

Verified on 8889

Archived the 482-entry demo survey from Settings → builder switched to the next form, the picker forgot it; the New-form dialog listed it with "482 entries · 500 submissions · 1200 views"; Restore brought it back open in the builder with everything attached.

Tests

New suite archive.php: status round-trips (publish→publish, draft→draft), entries leave the global list and return with read/unread intact while another form's entries never move, stats byte-identical across the trip, archived form closed to everyone (render + submit), REST list separation, and loud refusals for wrong moves. 698 PHPUnit + 353 vitest green, PHPCS clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp

A finished form is not a deleted form, and the trash is a place things go
to die. Archiving retires a form and everything that belongs to it in one
move: the form takes the atf-archived post status and leaves every picker,
its entries take a marker and leave the all-forms list and export, and its
stats — meta on the form — go wherever it goes. The availability gate
closes an archived form for everyone, editors included: the way past the
archive is unarchiving.

Unarchiving is the same move backwards, exactly: a draft comes back a
draft (never surprise-published), a read entry comes back read, and the
stats never move at all. The archive's door is the "Start a new form"
dialog — restoring a retired form is a way of getting a form — and the
Archive button lives in the form's own Settings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 6328533 into main Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant