getFormSchema is called on every 'next' in a wizard
Hi
it looks like the getFormSchema is called every time you press next in a wizard.
First I saw that it was taking a very long time when pressing the 'next', so I started to investigate
Here is a simple wizard that shows the error:
13 Replies
First time the component is loaded, the wizard shows, then when pressing 'Next' you will get errors
blade view for the wizard looks like this:
So the next does cause a refresh as standard Livewire as there could be changes etc. The problem from what I can see is you are passing it into a php method within the component. You should be calling the Wizard as a field inside the getFormSchema as the page variables are reset on livewire changes if they are not livewire named.
??
I'm trying to avoid that all controls are rebuild everytime you hit next
that goes against livewire, it's exactly what livewire does, as we get the next set of fields for the next step.. as far as I am aware, you cannot adjust this as the Wizard follows the principle of these approach.
sure It would be okay to rebuild for a spcific step, but that is not the case
So the way livewire works is, it sends a request to the server for every change. You are changing the step, so it passes the data back and then back again.
yes, but it keeps values in between
e.g. if I assign a private or public property a value it 's not lost during the life time of the component
with the wizard the values seems to be lost
That to me appears to be how you have built the component. $this->wzControl is being reset by the livewire component.
move the buildMyWizard to the getForm schema method.
no π
The whole point is that I would like to avoid rebuiling 200 controls every time
Ok, then I'm done trying to help! Have a good day π
moving the method does not change the fact that getformschema is called multiple times
But that is not normal of livewire component to reset values on a action
It is when they do not exists in the form.
You have declared wzControl in the loading of the component, but it doesn't exist within the request because it's not part of the form which is the container over the wizard, so it is dropped.