-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModal.php
46 lines (37 loc) · 854 Bytes
/
Modal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @copyright Copyright © Karnbrock GmbH, 2015
* @package yii2-modal-ajax
*/
namespace karnbrockgmbh\modal;
use karnbrockgmbh\modal\ModalAsset;
class Modal extends \yii\bootstrap\Modal {
/**
* The url to request when modal is opened
* @var string
*/
public $url;
/**
* Submit the form via ajax
* @var boolean
*/
public $ajaxSubmit = true;
/**
* @inheritdocs
*/
public function run()
{
$view = $this->getView();
parent::run();
ModalAsset::register($view);
$id = $this->options['id'];
$ajaxSubmit = $this->ajaxSubmit ? 'true' : 'false';
$js = <<<JS
jQuery('#$id').kbModalAjax({
url: '{$this->url}',
ajaxSubmit: {$ajaxSubmit},
});
JS;
$view->registerJs($js);
}
}