FilamentF
Filament13mo ago
Ryuuuu

statePath variable missing some form fields

so i have a few forms on the same page, using multiple forms like this. a couple of those forms have a problem, where only 2-3 of their fields, seemingly at random, will be "detached" from the form, i.e. the console throws a livewire error about "data.property" not found on component, and when inputting in those fields the data object will not update, and when trying to submit the form it will give a "property is required" error as if the field is empty (which it technically is since it never got updated inside the data variable). i've managed to fix this by changing my data definition from public ?array $data = []; to public ?array $data = ["property" => ""];, basically manually initializing only the problematic fields. this way the form works perfectly, including the non-problematic fields that i didn't manually initialize aswell as the problematic fields that are now fixed since i've manually initialized them. the fields themselves don't really have anything special and are delcared the same way as the other, working fields, using functions like TextArea::make() and TextInput::make. anyone have an idea of why just some fields would possibly me skipped from initialization? my workaround fix works right now but it feels kinda hacky and it would be better if i could fix the problem from the root.
Solution
Even if they don’t need default data you still have to call formFill in mount.
Was this page helpful?