I am making a comment system, livewire works correctly in other parts of the system but when I want to edit a comment the wire:model does not receive the information, however if I print the variable on the view it shows it correctly.
I show the code of the component:
public $editComment;
public function edit(Comment $comment)
{
$this->editComment = $comment;
}
public function mount()
{
$this->editComment = new Comment();
}
I show the view
@if($comment->user_id == Auth::user()->id)
<i title="Editar mensaje" wire:click="edit({{$comment}})" class="fas fa-edit"></i>
<i wire:click.prevent="confirmDelete({{$comment}})" title="Borrar mensaje" class="far fa-trash-alt"></i>
@endif
</div>
@if($comment->id == $editComment->id)
{{$editComment}} {{-- Here it shows it correctly --}}
<form wire:submit.prevent="update">
<input wire:model="editComment.comment" type="text">
The editComment variable looks like this:
{"id":153,"comment":"Primer comentario","user_id":1,"commentable_id":1,"commentable_type":"App\\Models\\Post","parent_id":null,"created_at":"2021-02-11T07:24:43.000000Z","updated_at":"2021-02-11T07:24:43.000000Z"}
When I try to access the editComment inside the wire:model it does not work. I have tried to access directly with editComment or editComment.comment . Neither of the 2 works.
What could be the error?