I have an array like this:
langs => [0=>'en',1=>'le'];
I have Foreach of langs with input like this:
<form wire:submit.prevent="store">
@foreach ($langs as $index => $lang)
<div wire:key="languages-{{ $index }}">
<label>{{ $lang }}</label>
<input type="text" wire:model="name.{{ $lang }}" />
@error('name.'.$lang) <span class="error">{{ $message }}</span> @enderror
</div>
@endforeach
<button type="submit" class="btn py-2 px-4 mt-7">
@lang('site.save')
</button>
</form>
Livewire component:
public $name = [];
protected $rules = [
'name.*' => 'required|string|min:5|max:100',
];
public function store()
{
$this->validate();
dd('sdf');
}
The validation does not work! and just pop up the dd that I have!!
Am I forget somethinng!?