A widget component for Yii Framework 2.0 to easily configure and initialize popup notification dialog boxes. It provides a polyfill for the native javascript alert, confirm, and prompt dialog boxes. It includes inbuilt support for rendering rich dialog boxes via bootstrap3-dialog which makes using Bootstrap's modal more monkey-friendly. The key features provided by the library are:
- Control how you want to render JAVASCRIPT dialogs. Inbuilt quick support for following dialog types:
- ALERT dialog
- CONFIRM dialog
- PROMPT dialog
- CUSTOM dialog
- Includes a jQuery plugin
krajeeDialog
(created by Krajee), that allows one to configure the bootstrap3-dialog library easily, or use the native JS alerting component, OR also configure any third party JS Notification Library to be used. - Advanced configuration via
kartik\dialog\Dialog
widget. This widget allows one to globally setup the native JS alert OR bootstrap3-dialog settings.
Demo ¶
You can see detailed documentation and demonstration on usage of the extension.
Installation ¶
The preferred way to install this extension is through composer.
Either run:
$ php composer.phar require kartik-v/yii2-dialog "*"
or add:
"kartik-v/yii2-dialog": "*"
to the require
section of your composer.json
file.
Usage ¶
Basic Usage ¶
In your view you can load the asset bundle and render the javascript to load the bootstrap 3 modal dialog.
// view.php
use kartik\dialog\DialogAsset;
DialogAsset::register($this);
$this->registerJs("\$('#your-btn-id').on('click', function() {
BootstrapDialog.alert('I want banana!');
});");
Advanced Usage (Widget) ¶
In your view OR view layout file, you can render the widget like this. This will not display any content directly - but will render all the javascript and css needed for initializing the BootstrapDialog as per your customized settings.
// view.php
use kartik\dialog\Dialog;
// Example 1
echo Dialog::widget([
'libName' => 'krajeeDialog',
'options => [], // default options
]);
// Example 2
echo Dialog::widget([
'libName' => 'krajeeDialogCust',
'options => ['draggable' => true, 'closable' => true], // custom options
]);
Report ¶
- Report any issues on the project page
- Use the forum page for any discussions on this extension
License ¶
yii2-dialog is released under the BSD 3-Clause License. See the bundled LICENSE.md
for details.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.