Inserting livewire component into a form, how to manage state?
Hello, following this section of the documentation: https://filamentphp.com/docs/3.x/forms/advanced#inserting-livewire-components-into-a-form
I have a wizard form with 3 steps to create a record of a resource.
The first two steps uses filament TextInput fields, the third step uses a livewire component.
When creating the record, the first two fields are automatically synced in the form state so when I create the record and inspect the data:
I have the values of the TextInput fields correctly:
My question is: How can I access the state of the form fields within the livewire component
Livewire::make(AppointmentSlotField::class)
and set new values to the form?
So when creating the record, I expect to have this output:
This is the livewire component:
Solution:Jump to solution
You can't do that, you would need to create a Filament Field component, opposed to a custom livewire component which does what you component does, just extends field opposed to component.
5 Replies
Bump.
After some research, I can manage the form state by propagating events up to the resource, but feels a bit hacky to me so I ended doing the opposite by creating a livewire component and adding a form to it, that way the form state can be easily managed.
But I'm still intrigued to know how you deal with the situation stated in the thread. Is it possible to manage the state directly within the component?
When adding a column User Encryption is disabled, it does not work, and when logging in, a message appears that the password is incorrect.
I think you answered in the wrong thread.
Solution
You can't do that, you would need to create a Filament Field component, opposed to a custom livewire component which does what you component does, just extends field opposed to component.
Thanks for your time toeknee, that solves my question.