-
Notifications
You must be signed in to change notification settings - Fork 1
/
ActiveFormButton.php
45 lines (36 loc) · 1.25 KB
/
ActiveFormButton.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
<?php
namespace pipekung\widgets;
use Yii;
use yii\helpers\Html;
/**
* Description of ActiveFormButton
*
* For example:
*
* echo ActiveFormButton::widget(['model' => $model]);
* ```
*
* @author Pipekung Specialz <chanja@kku.ac.th>
* @since 2.0
*/
class ActiveFormButton extends Widget {
public $model;
public function init() {
parent::init();
$this->options['class'] = 'col-sm-offset-2 col-sm-10';
}
public function run() {
echo Html::beginTag('div', ['class' => 'form-group']) . "\n";
echo Html::beginTag('div', $this->options) . "\n";
echo $this->renderItems() . "\n";
echo Html::endTag('div') . "\n";
echo Html::endTag('div') . "\n";
}
public function renderItems() {
$items = [
Html::submitButton($this->model->isNewRecord ? '<i class="glyphicon glyphicon-ok-sign"></i> ' . Yii::t('app', 'Create') : '<i class="glyphicon glyphicon-ok-sign"></i> ' . Yii::t('app', 'Update'), ['class' => $this->model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']),
Html::a('<i class="glyphicon glyphicon-remove-sign"></i> ' . Yii::t('app', 'Cancel'), ['index'], ['class' => 'btn btn-default']),
];
return implode("\n", $items);
}
}