my component livewire
public $images = [];
public function rules()
{
return [
'images.*.name' => 'required|max:255',
];
}
blade.php
<div id="images">
@foreach($images as $index => $image)
<div class="card" wire:key="image-field-{{$images[$index]['id']}}">
<img src="{{$images[$index]->original_url}}" class="card-img-top" alt="{{$images[$index]->name}}" />
<input type="text" name="item-{{$index}}-name" id="item.{{$index}}.name" wire:model="images.{{$index}}.name" />
<div class="card-footer">
<button wire:click="changeImageName({{$image['id']}},{{$images[$index]['name']}})">Update</button>
{{$images[$index]->name}}
</div>
</div>
@endforeach
</div>
so wire:model="images.{{$index}}.name" not working, not changing after typing
and update will error
Uncaught SyntaxError: identifier starts immediately after numeric literal
2
Answers
Make function update fix my problem
Maybe try adding the multiple attribute in the input tag. and change the wire:model value to just have images
I Hope that helps