falco442 / cakephp-3-sweet-alert-helper
SweetAlertHelper plugin for CakePHP
Installs: 1 379
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Language:JavaScript
Type:cakephp-plugin
Requires
- cakephp/cakephp: ^3.4
Requires (Dev)
- cakephp/cakephp-codesniffer: ^3.0
- phpunit/phpunit: ^5.7|^6.0
This package is not auto-updated.
Last update: 2024-11-20 14:53:13 UTC
README
Requirements
- CakePHP 3.x
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require falco442/cakephp-3-sweet-alert-helper
Usage
In your src/View/AppView.php
, put the helpers
public function initialize()
{
...
$this->loadHelper('SweetAlertHelper.Form');
$this->loadHelper('SweetAlertHelper.Html');
...
}
and in the template layout (or in the views), load the js file:
<?php
...
echo $this->Html->script('SweetAlertHelper.sweetalert2.min');
...
?>
Then you can use the confirm
option of
postLink
method ofFormHelper
link
method ofHtmlHelper
to show a Sweet Alert at the place of a normal alert, with your message:
<?= $this->Html->link('home',['action'=>'display','home'],['confirm'=>'Sei proprio sicuro?']); ?>
<?= $this->Form->postLink('home',['action'=>'display','home'],['confirm'=>'Sei proprio sicuro?']) ?>