Validate filament form without submitting
Hello guys, im trying to make a big form that has a really custom design, and this form would have multiple steps. But instead of using a single filament form with the step wizard, i went with 5 forms in the same page. This way i could write the step logic myself, using buttons and a step variable to determine which form to show based on the current step, so i could customize the design of the stepper entirely.
The problem now is that i can't seem to get the filament forms to validate separately when going to the next step. Trying to submit them using a form action gives a dd() kind of error message instead of just making the red text appear under each field. I assume this is because i don't have any function for the form to do in the form action. I would need just some sort of formaction that only does the validation and nothing else.
The forms all have their own validation rules, and at the last step i use the data variables in php to gather all of the users answers from the multiple form and do what i need with them. I have a different form variable and data variable in my page for each step, and they are defined properly using getForms() and statePath
Solution:Jump to solution
This will validate the forms
$this->form1->getState()
$this->form2->getState()
...5 Replies
yup
and then im using an Action:make() to make a button that submits them, but even tho the button is under 1 form, it submits all of them it seems
and also gives that error i talked about in the original post
Solution
This will validate the forms
$this->form1->getState()
$this->form2->getState()
if you are using a form submit, you should define different forms in the view as well
trying that rn
ok yeah thats exactly what i was looking for
i was actually looking at some other examples that had validations on the forms and just couldn't figure out where it was coming from
because the function was quite long
didn't cross my mind to check the getState function
as soon as you said that i remembered seeing them there and it all clicked
i wasn't able to find this info when googling either :))
but yeah thats perfect, i got it to work now in just a few lines changed
thank you so much