yii\grid\ActionColumn::initDefaultButton PHP Method

initDefaultButton() protected method

Initializes the default button rendering callback for single button
Since: 2.0.11
protected initDefaultButton ( string $name, string $iconName, array $additionalOptions = [] )
$name string Button name as it's written in template
$iconName string The part of Bootstrap glyphicon class that makes it unique
$additionalOptions array Array of additional options
    protected function initDefaultButton($name, $iconName, $additionalOptions = [])
    {
        if (!isset($this->buttons[$name]) && strpos($this->template, '{' . $name . '}') !== false) {
            $this->buttons[$name] = function ($url, $model, $key) use($name, $iconName, $additionalOptions) {
                $title = Yii::t('yii', ucfirst($name));
                $options = array_merge(['title' => $title, 'aria-label' => $title, 'data-pjax' => '0'], $additionalOptions, $this->buttonOptions);
                $icon = Html::tag('span', '', ['class' => "glyphicon glyphicon-{$iconName}"]);
                return Html::a($icon, $url, $options);
            };
        }
    }