Laravel

Livewire Form Wizard Pattern

January 16, 2026 1 min read 22 views

Multi-step form wizard:

Component

class RegistrationWizard extends Component
{
    public int $step = 1;
    public array $data = [];

    public function nextStep()
    {
        $this->validateStep();
        $this->step++;
    }

    public function previousStep()
    {
        $this->step--;
    }

    private function validateStep()
    {
        match($this->step) {
            1 => $this->validate(['data.email' => 'required|email']),
            2 => $this->validate(['data.name' => 'required']),
            default => null
        };
    }
}

View

@if($step === 1)
    
@elseif($step === 2)
    
@endif
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!