Answers for "laravel livewire validation message not showing"

1

livewire validation

$validatedData = $this->validate([
            'name' => 'required|min:6',
            'email' => 'required|email',
        ]);
Posted by: Guest on June-28-2021
0

Laravel Livewire Realtime validation

LARAVEL COMPONENT

class ContactForm extends Component { 
               public $name; 
               public $email;
               protected $rules = [
                 'name' => 'required|min:6',
                 'email' => 'required|email',
               ];
               public function updated($propertyName) {
                 $this->validateOnly($propertyName);
               }
               public function saveContact()
               {
                 $validatedData = $this->validate();
                 Contact::create($validatedData);
               }
             }

BLADE

        <form wire:submit.prevent="saveContact">
          <input type="text" wire:model="name">
          @error('name') <span class="error">{{ $message }}</span> @enderror

          <input type="text" wire:model="email">
          @error('email') <span class="error">{{ $message }}</span> @enderror

          <button type="submit">Save Contact</button>
      </form>
Posted by: Guest on September-23-2021

Code answers related to "laravel livewire validation message not showing"

Browse Popular Code Answers by Language