Hello everyone, 10+ years experienced dev new to payload and nextjs (have worked a bit with react before but never in production). We are currently evaluating payload for our agency, it still misses a couple features that we need. Nevertheless great already!
So one thing we are missing is a nested, sortable tree field. I thought to myself: if it does not exist, make it yourself. I am very close to a working custom field. I am using a JSON field to save my data.
Rendering subfields works with RenderFields works and writes into my JSON data correctly. But now comes the problem: I can't repopulate the fields again because useField({path}) cannot read from json fields. All in all this kind of makes sense to me.
Now that I am so close the end, I am sure there MUST be a way to accomplish this.:
<TextField
key={${path}.${item.getId()}.itemData.${field.name}}
field={field}
path={${path}.${item.getId()}.itemData.${field.name}}
/>
Is there no way to repopulate this with values other then the internal useField({path})? Can I somehow inject data in the datastore? I know this is probably an extreme edge-case. If you need any other info to look into it better, let me know.
And most importantly: I am very new to Payload and React, so code samples may be unoptimized and a bit wonky 🙂