/** * Initializes the default button rendering callbacks. */ protected function initDefaultButtons() { parent::initDefaultButtons(); if (!isset($this->buttons['active'])) { $this->buttons['active'] = function ($url, $model) { return Html::a('<span onclick="admin_api.request({id:' . $model['id'] . ', model:\'' . lcfirst((new \ReflectionClass($model))->getShortName()) . '\', method:\'post\', attributes:{active:' . ($model['active'] ? '0' : '1') . '}})" class="glyphicon ' . ($model['active'] ? 'glyphicon-ok' : 'glyphicon-ban-circle') . ' " style="color: ' . ($model['active'] ? 'yellow' : 'gray') . ' "></span>', '', ['title' => $model['active'] ? 'Отключить' : 'Включить']); }; } }
protected function initDefaultButtons() { parent::initDefaultButtons(); if (!isset($this->buttons['form-view'])) { $this->buttons['form-view'] = function ($url, $model, $key) { $options = array_merge(['title' => Yii::t('yii', 'Add'), 'aria-label' => Yii::t('yii', 'Add'), 'data-pjax' => '0'], $this->buttonOptions); return Html::a('<span class="glyphicon glyphicon-wrench"></span>', $url, $options); }; } }
protected function initDefaultButtons() { parent::initDefaultButtons(); if (!isset($this->actionName)) { $this->actionName = 'disable'; } if (!isset($this->buttons[$this->actionName])) { $this->buttons[$this->actionName] = function ($url, $model, $key) { $label = $model->{$this->stateAttribute} ? Yii::t('app', 'Enable') : Yii::t('app', 'Disable'); $options = array_merge($this->buttonOptions, ['title' => $label, 'aria-label' => $label, 'data-method' => 'post', 'data-pjax' => '0', 'class' => 'btn btn-block ' . ($model->{$this->stateAttribute} ? 'btn-success' : 'btn-danger')]); if (isset($this->confirmation)) { $options['data-confirm'] = $this->confirmation; } return Html::a('<span class="glyphicon glyphicon-ban-circle"></span> ' . $label, $url, $options); }; } }
/** * Initializes the default button rendering callbacks. */ protected function initDefaultButtons() { ActionAsset::register($this->grid->view); parent::initDefaultButtons(); if (!isset($this->buttons['up'])) { $this->buttons['up'] = function ($url) { $options = ArrayHelper::merge(['title' => Yii::t('hass', 'Up'), 'aria-label' => Yii::t('hass', 'Up'), 'data-pjax' => '0'], $this->buttonOptions); Html::addCssClass($options, "move-up"); return Html::a('<span class="glyphicon glyphicon-arrow-up"></span>', $url, $options); }; } if (!isset($this->buttons['down'])) { $this->buttons['down'] = function ($url) { $options = ArrayHelper::merge(['title' => Yii::t('hass', 'Down'), 'aria-label' => Yii::t('hass', 'Down'), 'data-pjax' => '0'], $this->buttonOptions); Html::addCssClass($options, "move-down"); return Html::a('<span class="glyphicon glyphicon-arrow-down"></span>', $url, $options); }; } }