Filament Form: Dynamic additional_fields values not being saved properly
Hi everyone,
I'm having an issue with dynamic fields in Filament where values entered in the form are not being captured properly during the save process.
My setup:
- I'm using a JSON column named
additional_fields
in my database
- In ProductResource, I dynamically generate form fields based on product groups
- These fields appear correctly in the form and I can enter values
- When I submit the form, all values in these dynamic fields become null or empty strings
Here's my current implementation:
The form logs show:
[2025-03-06] local.INFO: Düzeltilmiş form verileri: {"name":"product name","product_group_ids":["1","2"],"additional_fields":{"cinsiyet":"","etiketler":"","fiyat":"","tema":""}}
Despite entering values in the form, they always come through as null.
Has anyone encountered this issue before? Any suggestions on how to properly capture values from dynamic fields?2 Replies
I should also mention that when editing, the data is saved and comes in. This problem only occurs during the initial creation. https://codeshare.io/r4JJNq
Of course, I look forward to your help.
That
getAdditionalFieldsAttribute
and setAdditionalFieldsAttribute
is old Laravel syntax. On which version are you? Is it still supported? You can simply add a cast to your model:
Also, you don't need to ->dehydrate(true)
and I don't know if that interferes with default behaviour. But maybe that's from testing stuff.