For diagnostic, try a static text?
public function cancel() {
$this->desc = "Field was cleared";
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
What I have is quite simple. This is the structure in the HTML
<section x-data="{ isEditing: false }">
<div x-show="!isEditing">
<div>{{ $desc }}</div>
<button @click="isEditing=true">edit</button>
</div>
<div x-show="isEditing">
<textarea wire:model="desc"></textarea>
<button wire:click="save" @click="isEditing="false">save</button>
<button wire:click="cancel" @click="isEditing="false">cancel</button>
</div>
</section>
Then in the Livewire component I have this cancel function:
public function cancel() {
$this->desc = $this->whatever->desc;
}
What I intend to do is: the $this->desc is initialized on the mount() function and works perfectly. When I click "edit" on the HTML it shows the textarea with its data. Then I change something and click cancel. Since the textarea is bind to the desc variable it should return to the initial value, but when I click on edit again, it has the edited value and not the original one.
Even if I call $this->mount() the result is the same.
Do I have to refresh the textarea? I got no idea what to do. I even tried wire:model.live and does the same.
(Using Livewire 3)
Please or to participate in this conversation.