D
D
Daniil Sidorov2021-10-11 09:39:26
Yii
Daniil Sidorov, 2021-10-11 09:39:26

How to add a class to a button in Yii2-export?

Good afternoon. I'm using the Yii2-export extension . By default, the buttons created by the plugin have the class btn btn-outline-secondary. I am trying to insert the classes I need like this:

<?= ExportMenu::widget([
    'dataProvider' => $dataProvider,
    'dropdownOptions' => [
        'label' => 'Export',
        'class' => 'btn btn-primary btn-sm font-weight-bold',
        'icon' => '<i class="fas fa-external-link-alt icon-nm"></i>'
    ],
    'columnSelectorOptions' => [
        'icon' => '<i class="fas fa-list icon-nm"></i>',
        'class' => 'btn btn-primary btn-sm font-weight-bold',
    ],
    'exportConfig' => ...
    'columns' => ...
]); ?>

But in the end, the extension renders this:
<button id="w4-button" class="btn btn-primary btn-sm font-weight-bold btn-outline-secondary dropdown-toggle" title="Export data in selected format" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-external-link-alt icon-nm"></i> Эскпортировать</button>

That is, my classes were simply added to the beginning and overwritten by the default classes. How can I remove these classes by default?

I understand that the question is quite specific, but maybe someone used this plugin and faced such a problem.

*There doesn't seem to be a fix for this. I found this line in the source code
Html::addCssClass($this->dropdownOptions, ['btn', $this->getDefaultBtnCss()]);

That is, standard classes will always be added.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question