What seems to be the problem:
when i press enter it shows the validation correctly
but it doesn’t work live
I mean this should work without me pressing enter am I right?
SOLVED forgot the update method
Steps to Reproduce:
following video
Styling With Tailwind UI
Are you using the latest version of Livewire:
2.3
Do you have any screenshots or code examples:
<form wire:submit.prevent="register" action="#" method="POST">
<input type="hidden" name="remember" value="true">
<input wire:model="email" aria-label="Email address" name="email" type="email" placeholder="Email address">
@error('email')<div>{{ $message }}</div>@enderror
<button type="submit">
REGISTER
</button>
</form>
<?php
namespace App\Http\Livewire\Auth;
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Livewire\Component;
use Ramsey\Uuid\Exception\UnableToBuildUuidException;
class Register extends Component
{
public $email = '';
public $password = '';
public $passwordConfirmation = '';
public function updated($field) { $this->validate(['email' => 'unique:users']); }
public function register()
{
$data = $this->validate([
'email' => 'required|email|unique:users',
'password' => 'required|min:6|same:passwordConfirmation',
]);
$user = User::create([
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
auth()->login($user);
return redirect('/');
}
public function render()
{
return view('livewire.auth.register');
}
}**strong text**