Default values not applied in dynamically created form
I have the method below to dynamically build a form based on a JSON structure in a spatie settings row. The idea is create this form, fill it with the predefined default values from the DB and if I change something it changes it in the DB. This worked flawlessly with a flat array of key-value pairs. Now I needed to nest it and make it one layer deeper and it does not work anymore. When I ddd my fields or sections, I can see the default values but in the rendered form in the browser they are not there. This is the method to generate the form:
I am assuming it does not work because of using $typeKey and $safeKey and same matching does not work? I don't know really... I needed to create the $safeKey because Livewire would not render the page itself with using only $typeKey, I think because of some escaping issues.
Code is in the first answer (character limit)
I am assuming it does not work because of using $typeKey and $safeKey and same matching does not work? I don't know really... I needed to create the $safeKey because Livewire would not render the page itself with using only $typeKey, I think because of some escaping issues.
Code is in the first answer (character limit)
Solution
I used afterStateHydrated now to fill the config values into the fields. instead of default(). Seems to work for now.