yiisoft / yii2-bootstrap

Yii 2 Bootstrap 3 Extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
185 stars 193 forks source link

ActionColumn.php grid yii 2.1 with BS4. #241

Closed yii-bot closed 6 years ago

yii-bot commented 6 years ago

This issue has originally been reported by @cjtterabyte at https://github.com/yiisoft/yii2/issues/16359. Moved here by @samdark.


Yii Version; 2.1. Bootstrap: 4.1. PHP Version: 7.1.17. Operating System: Centos 7.

Hi, ActionColumn.php support icons glyphicons, Bootstrap 4.1.0 no support glyphicons, it should be rewritten so that the user indicates the icons to use, or use independent icons of BS3 and BS4 for default.

Code Glyphicons:


    /**
     * Initializes the default button rendering callbacks.
     */
    protected function initDefaultButtons()
    {
        $this->initDefaultButton('view', 'eye-open');
        $this->initDefaultButton('update', 'pencil');
        $this->initDefaultButton('delete', 'trash', [
            'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
            'data-method' => 'post',
        ]);
    }
    /**
     * Initializes the default button rendering callback for single button.
     * @param string $name Button name as it's written in template
     * @param string $iconName The part of Bootstrap glyphicon class that makes it unique
     * @param array $additionalOptions Array of additional options
     * @since 2.0.11
     */
    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) {
                switch ($name) {
                    case 'view':
                        $title = Yii::t('yii', 'View');
                        break;
                    case 'update':
                        $title = Yii::t('yii', 'Update');
                        break;
                    case 'delete':
                        $title = Yii::t('yii', 'Delete');
                        break;
                    default:
                        $title = ucfirst($name);
                }
                $options = array_merge([
                    'title' => $title,
                    'aria-label' => $title,
                ], $additionalOptions, $this->buttonOptions);
                $icon = Html::tag('span', '', ['class' => "glyphicon glyphicon-$iconName"]);
                return Html::a($icon, $url, $options);
            };
        }
    }
tecnoterabyte commented 6 years ago

ActionColumn.php belongs to the core framework, not the extension,

Thks,