fix: default virtual fields to readOnly in admin UI#16016
Merged
DanRibbens merged 1 commit intopayloadcms:mainfrom Apr 9, 2026
Merged
fix: default virtual fields to readOnly in admin UI#16016DanRibbens merged 1 commit intopayloadcms:mainfrom
DanRibbens merged 1 commit intopayloadcms:mainfrom
Conversation
DanRibbens
previously approved these changes
Mar 25, 2026
5833ea7 to
cc87e04
Compare
cc87e04 to
e4e2f43
Compare
PatrikKozak
approved these changes
Apr 9, 2026
Contributor
|
🚀 This is included in version v3.83.0 |
milamer
pushed a commit
to milamer/payload
that referenced
this pull request
Apr 20, 2026
### What? Virtual fields (`virtual: true` or `virtual: "path"`) now default to `admin.readOnly: true` during field sanitization. ### Why? Virtual fields are populated server-side and not persisted from user input. Without `readOnly`, users can type into them but edits are silently discarded on save — confusing UX with no indication the field is virtual. ### How? In `sanitize.ts`, after initializing `field.admin`, set `readOnly: true` for virtual fields unless the user has explicitly set `readOnly: false`. Fixes payloadcms#16013 Related payloadcms#16012
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Virtual fields (
virtual: trueorvirtual: "path") now default toadmin.readOnly: trueduring field sanitization.Why?
Virtual fields are populated server-side and not persisted from user input. Without
readOnly, users can type into them but edits are silently discarded on save — confusing UX with no indication the field is virtual.How?
In
sanitize.ts, after initializingfield.admin, setreadOnly: truefor virtual fields unless the user has explicitly setreadOnly: false.Fixes #16013
Related #16012