Single FileUpload inside state path saves differently as json
Not sure if this is intended behaviour but the file upload with single upload is saving as json with a random key when it's used inside a statePath.
E.g
image = "icon1.svg"
extra = "{ 'image': {'123':'icon2.svg'} }"
Tried to fix with afterStateUpdated but it's never called.
Solution:Jump to solution
since the file upload depends on those uuids to function properly, it would be better to format the form data before create / save instead of at the field level.
8 Replies
This is intended.
What's the idea behind it when it's only allowing one file to be uploaded?
Can it be overwritten so it only saves the file path?
I think you're maybe missing the idea of how the state and statePaths relate to the actual model and how the data gets saved to the db.
in your case, 'extra' should be a field in your DB for that model. and since it's a grid, the data has to be stored as json / array
Is there a way of overwriting how a state path is saved? I only want the json to be
"{ 'image': 'icon2.svg' }"
I thought Grid component was purely for display purposes.Layout components can also be used to group fields for relationships and since you aren't using a relationship it defaults to a json / array.
Solution
since the file upload depends on those uuids to function properly, it would be better to format the form data before create / save instead of at the field level.
I understand why it does it now thanks for explaining. Will look into doing it that way.