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

1.0.1 2018-03-09 16:33 UTC

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 of FormHelper
  • link method of HtmlHelper 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?']) ?>