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

mozew's avatar
Level 6

How to add link in sweet alert?

I want to add 2 links in sweet alert. but I see this picture.

sweet alert

alert()->warning("You must register now.<br>", 'OK')->html()->persistent("<a href='http://maneh.com/register' class='btn btn-primary'>register</a><a href='http://maneh.com/login' class='btn btn-primary'>login</a>");

How to add login and register buttons in sweet alert.

0 likes
7 replies
Cronix's avatar

You're using sweet alert, but also some laravel wrapper package for it. You'd have to check the docs for both, for the versions you are using of each. Sweet alert has made many changes over the years, so it depends on what version you are using.

mozew's avatar
Level 6

@cronix hi

I use laravel 5.8 version , and I installed last sweet alert

Cronix's avatar

I'm not talking about laravel. I'm talking about whatever PHP package you are using in laravel to use sweet alert. Sweet alert is a javascript package. You are using something else on top of that to use sweet alert in php.

alert()->warning("You must register now.<br>", 'OK')->html()

That's php, not the sweet alert javascript package (or you would be using pure javascript and NO php for sweet alert). You'll need to find out from whatever package that is...and read their docs.

You're using

  1. laravel 5.8
  2. some version of the javascript sweet alert library
  3. some version of a php wrapper library for that sweet alert javascript library
mozew's avatar
Level 6

I want to add two links in sweet alert

Cronix's avatar

Yep, that's pretty clear. What's not clear is what packages and versions of those packages you are using. Not sure how anyone can really help you without knowing that.

What package are you using to be able to use this in your php controller:

alert()->warning("You must register now.<br>", 'OK')->html()

Because that is not the regular Sweet Alert Javascript Library. I don't know what that is, and you did not say. How did you install that? Through composer, or through npm? What package is it? Do you have a link to the library?

Please or to participate in this conversation.