Custom component - replace array field values #718
Replies: 1 comment
-
Hey @lorenzowijtman — we just reviewed this at Payload and have understood your ask. The issue is that array and block fields actually only store the length of their array-based values within form state, and each field within each row of an array-based field stores its own value. So, when you use What we might be able to do instead is expose some specific actions within Or we could extend the In any case, the team is aware of this and is going to try and continue brainstorming how to give you what you need. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I might be missing something obvious but I am unable to replace/ update the value of a collection field with my custom component. The field is of the type
array
and stores an array of objects, which works well when creating the parent collection entry. However, when trying to update the value after creation, only the objects that exceed the length of the current array are added. So when creating the entry with an array of 10 objects, and trying to update the values afterwards with an array of 20 objects, only the objects 11-20 are added instead of replacing the values 1-10 as well.For a little bit of added context, The parent collection is a leaderboard which has the array field of objects for the ranks as follows
The custom component accepts csv or xlsx files that contain rows which are converted to the array of objects to be stored for which I use
setValue
ofuseFieldType
. When the leaderboard exists with rankings, after uploading a new file with "updated" rankings, I see the new values in the UI for a second through thevalue
variable before it flashes back to the original values that are in the database or with only the exceeding values added as mentioned above.Beta Was this translation helpful? Give feedback.
All reactions