Reputation: 21
I have this code in blade I try to set value of item quantity to input type="text" which inside @foreach ..... @endforeach for updating value each one alone.
@foreach ($Carts as $index => $Cart)
<input type="text" wire:model="Quantity.{{ $index }}" value="{{ $Cart->items_qty }}"/>
@endforeach
Code in Component
public $BarcodeSearch, $Quantity;
public function render()
{
return view('livewire.cashier',[
'Carts' => Cart::all()
]);
}
How do I show the value in the fields? "Quantity"
The picture is for clarification
Upvotes: 1
Views: 1849
Reputation: 41
To display the Quantity of your component you should use :
{{ $cashier->Quantity }}
You can't use it like this
wire:model="Quantity.{{ $index }}"
because this is not how model works.
Model is based on wire:model="PropertyToMonitor"
or wire:model="ParentComponent.PropertyToMonitor"
. See documentation of model here
Upvotes: 0