Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PeterGary's avatar

Livewire wire:dirty message doesn't hide by default.

Hello. I have a very simple form with the wire:dirty property. In my case, the dirty state is active by default. Always after refreshing the page, the message "Unsaved changes..." is visible, even though the input element contains exactly the same value as the variable on the server side. Only when I manually modify the value of the input element in the frontend and then revert to the previous value does the message disappear. What did I do wrong? This is a problem for me because when I open the final form for editing and fill all the fields with data from the database, livewire considers all the fields dirty. Please help because I can't find the answer anywhere.

Thank you in advance.

0 likes
4 replies
joffreypersia's avatar

Hi,

It is always better to show your code so we can understand it better. We're programmers :)

Based on the doc, it should be like this :

<form wire:submit="update">
    <input type="text" wire:model="title">
 
    <!-- ... -->
 
    <button type="submit">Update</button>
 
    <div wire:dirty>Unsaved changes...</div> 
</form>

https://livewire.laravel.com/docs/wire-dirty#basic-usage

PeterGary's avatar

@joffreypersia Thanks for the help.

My code for testing the dirty directive is super simple :)

class DirtyTest extends Component
{
    public $name = "Adam";
    
    public function render()
    {
        return view('livewire.dirty-test');
    }
}

and blade

<form wire:submit="update">
    <input type="text" wire:model="name" class="...">  
 
    <button type="submit">Update</button>
 
    <div wire:dirty>Unsaved changes...</div> 
</form>

It seems that the problem occurs only on my local environment (Herd) and only in the office. I am at home now and everything works fine on both Herd and the production server. Thanks again.

1 like
joffreypersia's avatar

@PeterGary Probably a cache problem then

Don't hesitate when you see a weird behavior to clear cache on your browser and on the app.

php artisan optimize:clear

Have a great day :)

PeterGary's avatar

Ok I found the cause. My mistake. I didn't notice that in the office I had inserted the blade directive @livewireScripts in the layout app.blade.php. After removing it, everything works like a charm. Best regards and have a nice day.

1 like

Please or to participate in this conversation.