Validation always required on drafts/revisions
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 28/100
Rechercherichtung
Start in the Blueprint field's Field::rules(), which the issue names as the place where the 'Required' toggle is prepended, then follow where entry validation runs on publish versus draft/working-copy saves. Read the closed PR #8919 and the linked ideas#765 for the earlier attempt that skipped all validation on drafts, since that is the behaviour being narrowed. Expect a decision on how the required toggle interacts with the marker before any patch; done means drafts skip marked rules while published saves and publishing a working copy still run them, with tests covering users/terms/globals which must ignore the marker.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Bug description
Saving a draft, or a working copy when revisions are on, runs every validation rule. An editor can't save an entry that is still missing a required field, even though nobody can see it yet.
A typical case: a client starts an entry before they have the hero image or the final copy. The image is required, so the save fails. They end up uploading a placeholder or leaving the tab open.
How to reproduce
- Add a required field to a collection blueprint, e.g. an
assetsfield. - Create an entry, fill in only the title, and leave it unpublished.
- Save. It fails with "This field is required."
Logs
No response
Environment
Statamic 6.43.1 PRO
Installation
Fresh statamic/statamic site via CLI
Additional details
Proposal
Use the special rule Jason suggested when closing #8919 (https://github.com/statamic/cms/pull/8919#issuecomment-1994513035): a when_publishing marker in a field's validate rules. Rules listed above when_publishing always run. Rules listed below it are skipped on drafts and only run when the entry is published.
validate:
- 'max:5'
- when_publishing
- required
- 'min:2'
The details we'd suggest:
- It only affects rules listed in
validate. A fieldtype's own rules always run, so an integer field still has to be an integer on a draft. - Marked rules run when saving a published entry or publishing a working copy. They're skipped when saving a draft or a working copy.
- The "Required" toggle is added ahead of the
validaterules inField::rules(), so it can never fall after the marker. This needs a decision. One option: when the marker is present, treat the toggle as publish-only too. - Title stays required unless the collection has a title format, as it is today.
- Blueprints with no published state (users, terms, globals) ignore the marker and always run every rule.
- It's opt-in per field, so it isn't breaking and could go in 6.x. Whether drafts should skip
requiredby default is a separate question for 7.x.
Related
- #8919: the closed PR that skipped all validation on drafts.
- statamic/ideas#765: the same request for working copies.
- #10515: autosave can't start on a new entry.
- Vorherrschende Sprache
- PHP
- Sterne
- 4.9k
- Forks
- 647
- Ø Merge
- 1 T. 45 Min.
- Gemergte PRs (30 T.)
- 221
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus statamic/cms
-
forms ui
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
accessibility
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
antlers
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Maintainer antworten meist innerhalb von 1 Tag
-
Nav: link to the site root with an anchor (/#section) gets is_parent on every pageEvtl. vergeben @duncanmcclean hat das heute übernommen. Offennavigations
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
Multiple Choice and Checkboxes no longer offer "Inline", but the default views still use itEvtl. vergeben @duncanmcclean hat das heute übernommen. Offenforms
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue help wanted up-for-grabs
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
AnikethTS/RunnerDeck#307 ·
Maintainer antworten meist innerhalb von 1 Tag
-
sync-en
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
sync-en
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag
-
Перевод устарел
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag