Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Livewire

Building Multi-Step Forms with Livewire v4

Create wizard-style multi-step forms.

1 February 20261 min readLivewireاقرأ بالعربية

On this page

  1. Component

Build multi-step form wizards.

Component

php
@php
new class extends Livewire\Component {
    public int $step = 1;
    public string $name = '';
    public string $email = '';
    public string $plan = '';
    
    public function nextStep(): void
    {
        $this->validateCurrentStep();
        $this->step++;
    }
    
    public function prevStep(): void
    {
        $this->step--;
    }
    
    private function validateCurrentStep(): void
    {
        match($this->step) {
            1 => $this->validate(['name' => 'required']),
            2 => $this->validate(['email' => 'required|email']),
            default => null,
        };
    }
}
@endphp
All articles

Keep reading

  • Authorization in Livewire v4 Components1 February 20261 min read
  • Blaze Pre-Compiler: Massive Performance Gains in Livewire v41 February 20261 min read
  • Building a Bookmark Feature with Livewire v41 February 20261 min read