Create dynamic model name in livewire 3
To, create dynamic wire:model name in livewire 3 follow the below code,
file.blade.php
@for($i=0;$i<10;$ )
<input type="text" name="" wire:model="quantity.{{ $i }}" wire:change="updateQuantity({{ $i }})">
@endfor
file.php
public $quantity = [];
public function updateQuantity($id)
{
$this->quantity[$id] = 100;
}
If you don't understand that here is a another code for the logic,
public $dynamicMapping = [];
public $inputID;
<input wire:model="dynamicMapping.{{$inputID}}">
I hope you understand that happy coding