jantinnerezo / livewire-alert

SweetAlert2 wrapper for Livewire
https://livewire-alert.jantinnerezo.com
MIT License
682 stars 73 forks source link

preConfirm value #131

Open bucari opened 8 months ago

bucari commented 8 months ago

Hi, after updating to livewire-alert 3, value in preConfirm is not anymore in $data passed to onConfirm function

            $this->confirm('Rifiutare il documento n° '. $id . '?', [ 
                'inputAttributes' => ['id' => $id],
                'onConfirmed' => 'rejectConfirmed',
                'focusConfirm'=> false,
                'input' => 'text',
                'inputLabel' => 'Motivo del rifiuto',
                'preConfirm' => '(value) => {'.
                    'if (!value) {'.
                    ' Swal.showValidationMessage('.
                    "   '<i class=\"fa fa-info-circle\"></i> Indicare il motivo di rifiuto'".
                    ' )'.
                    '}'.
                  '}'
            ]);

then in

    #[On('rejectConfirmed')]
    public function rejectConfirmed($data)

$data contains only inputAttributes array

sontungx305 commented 8 months ago

Have you been able to solve it yet? I have the same problem.

bucari commented 8 months ago

Unfortunately not

sontungx305 commented 8 months ago

I found the solution.

Try adding $value param to rejectConfirmed function.

public function rejectConfirmed($data, $value)

bucari commented 8 months ago

Thank you, i will try

ezehkingsleyuchenna commented 7 months ago

I found the solution.

Try adding $value param to rejectConfirmed function.

public function rejectConfirmed($data, $value)

This worked for me. Thank you.