uxweb / sweet-alert

A simple PHP package to show SweetAlerts with the Laravel Framework
MIT License
834 stars 208 forks source link

SweetAlert warning: "type" option has been deprecated. Please use "icon" instead. #106

Closed kriiv closed 4 years ago

kriiv commented 4 years ago

Getting this error. On dev-master Laravel 6. Pulling sweetalert.js (2.1.2) from Cloudflare.

SweetAlert warning: "type" option has been deprecated. Please use "icon" instead.

thewebartisan7 commented 4 years ago

It's just a warning, you can safetly ignore it.

kriiv commented 4 years ago

It's a warning but I am doing something like Alert::success(etc etc); and no icon 'tick' is showing because of it.

thewebartisan7 commented 4 years ago

Sorry seem that you are right, I just come today to this package, and I didn't test it enough.

The problem can be solved quickly, by changing here:

https://github.com/uxweb/sweet-alert/blob/master/src/SweetAlert/SweetAlertNotifier.php#L82

to:

$this->config['icon'] = $icon;

thewebartisan7 commented 4 years ago

Without changing package code, if you publish the view and use your custom, this can be a workaround:

@if (Session::has('sweet_alert.alert'))
    <script>
        @if (Session::has('sweet_alert.content'))
            var config = {!! Session::pull('sweet_alert.alert') !!}
            config.icon = config.type;
            delete config.type;
            var content = document.createElement('div');
            content.insertAdjacentHTML('afterbegin', config.content);
            config.content = content;
            swal(config);
        @else
            var config = {!! Session::pull('sweet_alert.alert') !!}
            config.icon = config.type;
            delete config.type;
            swal(config);
        @endif
    </script>
@endif
kriiv commented 4 years ago

You are AWESOME.

I published the view and made the changes you suggested. Works perfectly.

AngusDV commented 4 years ago

go to https://github.com/uxweb/sweet-alert/issues/64

seongbae commented 4 years ago

Sweet. Thanks @thewebartisan7 !