I'm trying to create a generic hook for setting a default value on a field on save, but whenever someone saves the document, the field key is not there when the field has not been filled in by the user.
Would it possible to to get the available fields for a collection while in a hook?
Well, I think I answered my own question. For future reference:
You can get the
req
object in a hook, which includes a
collection
key
So you can access the configured fields like this:
req.collection.config.fields
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.