livewire validation
$validatedData = $this->validate([
'name' => 'required|min:6',
'email' => 'required|email',
]);
livewire validation
$validatedData = $this->validate([
'name' => 'required|min:6',
'email' => 'required|email',
]);
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>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us