Storing objects in a field?
See original GitHub issueNot so much of an issue, more a question: I’d like to store lists and objects in a field, is that possible?
For example, we have image uploads which always come as { uid, caption, url }
object. We have single image uploads (e.g., a profile photo) or lists of uploads (e.g., photos on a blog post), which can be edited (i.e., adding, removing, changing the caption) in a form.
It doesn’t work setting the array or object directly in the field. Updates to the field (using field.set()
) do not trigger a change in the form model.
Should I be using nested fields for this? If so, how would I specify a field containing a list with { uid, caption, url }
objects in it, using unified notification?
What does work though is serializing the array or object to JSON and then putting this into the form. This is a bit inconvenient though.
Thanks!
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (6 by maintainers)
Top GitHub Comments
Well just as an update: Found out what the problem was… The component with the form was reinitialized for some weird reason which led also re-initializing the form and overwriting the updated value again. Though your hint @foxhound87 with using
update()
for nested fields was quite useful, thanks! 👍Oh sorry, that just happened when copying it over to GH… Well i’ll try to get it working somehow, but thanks for your help anyways!