kartik-v / yii2-widgets

Collection of useful widgets for Yii Framework 2.0
http://demos.krajee.com/widgets
Other
558 stars 175 forks source link

Select2 options and style not working #306

Open tifaucz opened 8 years ago

tifaucz commented 8 years ago

I have the following Select2:

<?= $form->field($model, 'subgrupo_id')->widget(Select2::classname(), [
                                    'data' => ArrayHelper::map(ProdutoSubgrupo::find()->orderBy('descricao')->all(), 'id', 'descricao'),
                                    'pluginOptions' => ['allowClear' => false],
                                    'hideSearch' => true,
                                    'options' => [
                                        'placeholder' => 'Selecione',                                           
                                    ],
                                    'addon' => [
                                        'append' => [
                                            'content' => Html::button('<i class="fa fa-plus font10"></i>',[
                                                'class' => 'btn btn-primary',
                                                'title' => 'Novo Subgrupo',
                                                'data-toggle' => 'tooltip',
                                                'id' => 'btnNovoSubgrupo',
                                            ]),
                                            'asButton' =>true,
                                        ],
                                    ],
                                ]);
                                ?>

And tried to use this extension to make this one:

<?php echo $form->field($model, 'subgrupo_id')->widget(DepDrop::classname(), [
                                    'options'=>['id'=>'subgrupo_id', 'placeholder' => 'Selecione'],
                                    //'pluginOptions' => ['allowClear' => false],
                                    //'hideSearch' => true,
                                    'pluginOptions'=>[
                                        'depends'=>['grupo_id'],
                                        'placeholder'=>'Selecione',
                                        'url'=>Url::to(['/produto/subgrupo']),
                                        'label'=>''
                                    ],
                                    'select2Options' => [
                                        'pluginOptions'=>['allowClear' => false],
                                        'pluginOptions' => ['allowClear' => false],
                                        'hideSearch' => true,
                                        'addon' => [
                                            'append' => [
                                                'content' => Html::button('<i class="fa fa-plus font10"></i>',[
                                                    'class' => 'btn btn-primary',
                                                    'title' => 'Novo Subgrupo',
                                                    'data-toggle' => 'tooltip',
                                                    'id' => 'btnNovoSubgrupo',
                                                ]),
                                                'asButton' =>true,
                                            ],
                                        ],
                                    ],

                                ])

However, some options like the append button are not showing, and also its not following the same style as a normal Select2.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/34916349-select2-options-and-style-not-working?utm_campaign=plugin&utm_content=tracker%2F530581&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F530581&utm_medium=issues&utm_source=github).