-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read-only fields show and are editable when creating new document. #105
Comments
Hey @richardvanbergen , This is actually intended behavior that we settled on while designing the We thought that in order for a field to be "read", its value must be set in the first place. While a value could be set with hooks or through APIs, given that this command only affects the admin panel, we determined that To disable your field within the {
label: 'S3 URL',
name: 's3Url',
type: 'text',
admin: {
readOnly: true,
},
access: {
create: () => false,
},
hooks: {
beforeChange: [
(): undefined => undefined,
],
afterRead: [
({ data }): string => {
return getUrl(String(data.filename))
}
]
}
} I am open to revisiting the However, our above use-case could be solved the same way through access control functions. Thoughts? |
Update: Changing Nice and easy. I'm up for it... |
@richardvanbergen In addition to the above fix, you'll likely want to use a condition to hide the field if it is not populated like this:
|
I agree, In a future update we could allow a function call that returns |
Thanks guys that all makes a lot of sense. I didn't really have a use case for it because we're all about the content editing and less so about transactions. Sorry about the late reply I kind of forgot I filed this bug report 😆 |
Bug Report
As discussed in #98 I created a virtual field like so:
When editing an existing document, we get a disabled text input with the correct text.
However when creating a new document, we get an empty text area that the user can edit.
Expected Behavior
Ideally, unless there's a reason no to we should not see the read-only field at all until the document is created.
Current Behavior
Shows editable text input.
Steps to Reproduce
{admin: {readOnly: true}}
.Detailed Description
Payload version: 0.4.4
The text was updated successfully, but these errors were encountered: