JSON keys get overriden if they are not used in a form.
I am trying to modify some keys in a json array for a Spatie Media item. The json array has values that are not exposed to the front end.
I have a custom_properties.width / custom_properties.height that is being set through a job, so these values don't make sense to be a part of the form builder.
When I save my model, the entire json array is overriden instead of just the keys I am accessing.
I would love to know if this is a bug or if I missing something to tell filament to only update those keys.
Solution:Jump to solution
I appreciate the reply! I may look into making an issue for it and see if I can make a PR for it.
For future people looking at this, this is how I solved it:
```...
4 Replies
I don't think it's a bug. It's probably just filling the whole array. So if you want to keep data that's not in the form you probably need to backfill those via
mutateDataBeforeSave
I think this could be labeled as a bug. I can't imagine a usecase where someone would be editing a specific key in an array and would want the entire array to be overriden.
I agree that it might not be expected.
In the end this is just a simple
Model::update(..)
. If the data is not there it will be overwritten.Solution
I appreciate the reply! I may look into making an issue for it and see if I can make a PR for it.
For future people looking at this, this is how I solved it: