Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

livewire model bind item in array

#Using a multi-dimensional array that looks like this:
$data = [
   1 => ['name' => 'Name', 'completed' => 0],
   2 => ['name' => 'Name 2', 'completed' => 1],
];
#Bind items like so:
@foreach ($items as $item)
   <x-input wire:model="data.{{ $item->id }}.name" type="text" />
   <x-input wire:model="data.{{ $item->id }}.completed" type="checkbox" />
@endforeach
Source by laracasts.com #
 
PREVIOUS NEXT
Tagged: #livewire #model #bind #item #array
ADD COMMENT
Topic
Name
9+5 =