This is my blade template
<form wire:submit="save">
<input wire:model="name" value="">
<input type="radio" wire:model="gender" value="male">Male
<input type="radio" wire:model="gender" value="female">Female
<button type="submit" class="btn btn-primary">Register </button>0
</form>
This is create component in livewire
class Create extends Component
{
#[Validate('required')]
public $name;
#[Validate('required')]
public $gender;
public function save(){
dd($this->gender);
$validated = $this->validate();
$newPatient = Patient::create($validated);
}
}
When I click save button on empty form, it asks to fill fields, that is fine. But after filling all, the form is not saving data. Just Radio Button gets focusing. dd()'
ing the gender
returns correct value. I don’t know why the form is not saving when $this->validate()
is called.
And if I remove $this->validate()
method, the form is saving data normally.
Please help me
if I remove $this->validate()
method, the form is saving data normally.