SweetAlertHelper plugin for CakePHP
Requirements
Installation
You can install this plugin into your CakePHP application using composer., (*1)
The recommended way to install composer packages is:, (*2)
composer require falco442/cakephp-3-sweet-alert-helper
Usage
In your src/View/AppView.php
, put the helpers, (*3)
public function initialize()
{
...
$this->loadHelper('SweetAlertHelper.Form');
$this->loadHelper('SweetAlertHelper.Html');
...
}
and in the template layout (or in the views), load the js file:, (*4)
<?php
...
echo $this->Html->script('SweetAlertHelper.sweetalert2.min');
...
?>
Then you can use the confirm
option of
* postLink
method of FormHelper
* link
method of HtmlHelper
to show a Sweet Alert at the place of a normal alert, with your message:, (*5)
<?= $this->Html->link('home',['action'=>'display','home'],['confirm'=>'Sei proprio sicuro?']); ?>
<?= $this->Form->postLink('home',['action'=>'display','home'],['confirm'=>'Sei proprio sicuro?']) ?>