You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a Payload CMS app and have a specific requirement: when creating a document in one collection, another document should be created as a draft in a different collection.
Example: When an order is created, an application form should be created as a draft in the awardApplications collection, using some fields from the created order.
To achieve this, I am using the afterChange hook in the orders collection configuration. Here is the code for the hook:
but error on awardApplications The following fields are invalid: First Name, Last Name, Email, Phone........
This behavior seems inconsistent with the Payload CMS documentation on drafts https://payloadcms.com/docs/versions/drafts#draft-api
If draft is enabled while creating or updating a document, all fields are considered as not required, so that you can save drafts that are incomplete.
I am saving the document with the _status set to 'draft', so it should not trigger validation errors for required fields.
Describe the Bug
I am working on a Payload CMS app and have a specific requirement: when creating a document in one collection, another document should be created as a draft in a different collection.
Example: When an order is created, an application form should be created as a draft in the awardApplications collection, using some fields from the created order.
To achieve this, I am using the afterChange hook in the orders collection configuration. Here is the code for the hook:
but error on awardApplications
The following fields are invalid: First Name, Last Name, Email, Phone........
This behavior seems inconsistent with the Payload CMS documentation on drafts
https://payloadcms.com/docs/versions/drafts#draft-api
If draft is enabled while creating or updating a document, all fields are considered as not required, so that you can save drafts that are incomplete.
I am saving the document with the _status set to 'draft', so it should not trigger validation errors for required fields.
Link to the code that reproduces this issue
https://github.com/payloadcms/payload/tree/main/templates/website
Reproduction Steps
If I set all fields in the awardApplications configuration to required: false, I can successfully save the document in awardApplications.
Which area(s) are affected? (Select all that apply)
Not sure
Environment Info
The text was updated successfully, but these errors were encountered: