Validation always required on drafts/revisions
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- PHP
- 星标
- 4.9k
- 派生
- 647
- 平均合并
- 1 天 45 分钟
- 30 天内合并 PR
- 221
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
statamic/cms 的其他 Issue
-
forms ui
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
accessibility
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
antlers
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
Nav: link to the site root with an anchor (/#section) gets is_parent on every page可能已有人在做 @duncanmcclean 今天认领。 未关闭navigations
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 1 天内回复
-
Multiple Choice and Checkboxes no longer offer "Inline", but the default views still use it可能已有人在做 @duncanmcclean 今天认领。 未关闭forms
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
sync-en
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
taskforcesh/bullmq#5238 ·
维护者通常 1 天内回复
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects it可能已有人在做 @bfs2021 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
Automattic/jetpack#55517 ·
维护者通常 1 天内回复