Validation always required on drafts/revisions
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 28/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- PHP
- Star
- 4.9k
- Fork
- 647
- Merge trung bình
- 1 ngày 45 phút
- Pull request đã merge (30 ngày)
- 221
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của statamic/cms
-
forms ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
accessibility
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
antlers
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Nav: link to the site root with an anchor (/#section) gets is_parent on every pageCó thể đã có người làm @duncanmcclean đã nhận hôm nay. Đang mởnavigations
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Multiple Choice and Checkboxes no longer offer "Inline", but the default views still use itCó thể đã có người làm @duncanmcclean đã nhận hôm nay. Đang mởforms
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Selection on a line without a docblock tag drops trailing characters (data provider attribute)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vimeo/psalm#15150 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
taskforcesh/bullmq#5238 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itCó thể đã có người làm @bfs2021 đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Automattic/jetpack#55517 ·
Maintainer thường phản hồi trong vòng 1 ngày