Improve defaultValue types and allow relationship to accept more than a function #1720
Replies: 5 comments 3 replies
-
|
Hey @evelynhathaway — this is all good stuff! I agree with everything that you're saying. I believe the reason we restricted the In addition, I think that we can improve the types here so that the Going to add this to our roadmap priority 2 and convert it to a discussion. This would also be a great PR if you are looking to contribute! Otherwise the Payload team will definitely address this. Thank you!! |
Beta Was this translation helpful? Give feedback.
-
|
The documentation also doesn't explain how to set a defaultValue for an array |
Beta Was this translation helpful? Give feedback.
-
|
Oh man I just lost a few hours to this, let's update the docs! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
For anyone wondering how to pass default data to an array, debug it with the admin condition and pass a similar structure to your default value |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
Documentation Issue
The relationship field documentation doesn't provide a description of the type or what data should be included for the
defaultValueoption.Improving the TypeScript types for
CollectionConfigand the documentation could help new users.Additional Details
I ran into errors while trying to add a default value to a relationship field
I had to dive into the source code to find it only accepts a function
payload/src/fields/config/schema.ts
Lines 313 to 315 in 934b443
Before I found that, I tried using:
idas a stringnameas a string withuseAsTitle: 'name'on the related collectionidstype ValueWithRelationValueWithRelationobjectsBeta Was this translation helpful? Give feedback.
All reactions