Replies: 1 comment
-
Hmm, I would say that you should use collection hooks for now but this is something that should ultimately be addressed by Payload. I will add this to our Roadmap Priority 3 and we will address shortly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In some collections we're using an explicit
id
, as described here: https://payloadcms.com/docs/fields/overview#customizable-idIn some situations we need to explicitly set the id with a value from a legacy system, but when a user creates a new document in the admin ui and doesn't provide an id, we want to generate a random uuid.
My initial idea was to create a
beforeValidate
field hook that would generate the id if not provided, but I found that this only updates theid
property, but not the underlying_id
field. Is this a missing feature, or is this by design?Other side of this is that if I do enter a value and then change it in the
beforeValidate
field hook, since the original value is still in the_id
property, that is what gets saved and the updated value is lost.Of course I can still achieve the required functionality by using a collection hook.
Beta Was this translation helpful? Give feedback.
All reactions