Field is still saved even though it is set to read-only #5954
Replies: 1 comment 2 replies
-
Hey @CherryDT — there are a few complexities with this that make it somewhat difficult to accomplish what you're looking for without some side-effects. Marking a field as There are some alternatives, though. You can use Alternatively, you could add a We might be able to solve for this at some point in the near-future, but it likely will be against 3.0. I will mark this as a Feature Request for now and we will keep an eye on interest for this topic. If more people show interest, we will prioritize a way to make this happen! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Link to reproduction
No response
Describe the Bug
I've set a field (a transaction status) to read-only so that it is visible in the admin but the user can't change it through normal means (because it would cause a problem with the user opening the form to change something else, the system updating the status elsewhere in the meantime and then the user saving the form and inadvertedly resetting the transaction status back to what it was before).
However, I noticed it's still sent in the form payload and overwrites the data in the database when saved. I don't see why it would need to be sent here, if it's not meant to be changed anyway.
(Yes, I could use
access
to prevent writing to it, but that's not good either because other parts of the system may want to write to this field through the API, in a controlled manner, but also with the user's credentials.)To Reproduce
Set a field to read-only.
Open the edit form.
Change the field through API or directly in the DB.
Submit the edit form.
Note that the value was reset to what it was when the edit form was opened.
Payload Version
2.12.1
Adapters and Plugins
db-mongodb, bundler-webpack
Beta Was this translation helpful? Give feedback.
All reactions