Replies: 1 comment 4 replies
-
You probably need to use an initial state. See https://spatie.be/docs/laravel-livewire-wizard/v2/usage/setting-initial-state. This will allow you to fetch the state from the database and make it available in all steps. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want the ability to store a form wizards state in the database. I think this is really important for multi-step wizards as people may leave the page on accident.
On first load I check to see if a user has a previous wizard via a cookie:
submit()
is called once the user completes the first step I create the wizard record and save it's ID to a cookieAt each step submit, before
nextStep()
is called. I save the state.The problem I am facing is when 1 happens above and I want to be able to access the database entry ID without attempting to get the cookie in subsequent steps. How can I store the entry ID to the global state? I've tried:
which works when the user already has a database entry, however when the user doesn't and this code triggers on the first step:
a dd of
$this->state()->get('qid')
beforenextStep()
is called shows the ID persisting, but when I reach the next step the ID is not there.@freekmurze I would really appreciate it if you could take a look, your packages have greatly helped me over the years so I hate to ask more of you, but I've been wracking my brain on this one.
QuestionnaireComponent.txt
QuestionnaireMounterTrait.txt
AuthorizationStepComponent.txt
Beta Was this translation helpful? Give feedback.
All reactions