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

onurzdgn's avatar

Livewire Error not Working Second Time

Hi everyone. I am using Laravel 10 and Livewire 3. I am trying to create success and error messages. It is working save with successful or error, it gives me error. However, when I try to save second time it not giving error. This is my livewire controller:

 public function profilePassword()
    {
        $this->validate();

        if (!Hash::check($this->password, auth()->user()->password)) {
            session()->flash('message', ['I hope this time you give me correct password', 'Try again']);
            $this->reset();
        }
    }

This is my error message:

@if (session()->has('message'))
            @script
                <script>
                    error();

                    function error() {
                        toastr.error("{{session()->get('message')[1]}}", "{{session()->get('message')[0]}}", {
                            positionClass: "toast-top-right",
                            timeOut: 5e3,
                            closeButton: !0,
                            debug: !1,
                            newestOnTop: !0,
                            progressBar: !0,
                            preventDuplicates: !0,
                            onclick: null,
                            showDuration: "300",
                            hideDuration: "1000",
                            extendedTimeOut: "1000",
                            showEasing: "swing",
                            hideEasing: "linear",
                            showMethod: "fadeIn",
                            hideMethod: "fadeOut",
                            tapToDismiss: !1
                        })
                    }
                </script>
            @endscript
        @endif

This is my themes custom errors. Please ignore error messages these are not real.

0 likes
3 replies
medcharrafi's avatar

@onurzdgn i think the issuue might be related to the fact that Livewire does not re-render the entire componeent on the second submmission and thus, the Livewire component's scripts are not being reloaded might be you must dispatczh an event after the flash message

Please or to participate in this conversation.