kartik-v / yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
http://demos.krajee.com/widget-details/select2
Other
323 stars 145 forks source link

[fix] allow theme to be overriden by pluginOptions #218

Closed maurice-pega closed 7 years ago

maurice-pega commented 7 years ago

Scope

This pull request includes a

Changes

The following changes were made

kartik-v commented 7 years ago

Why is this needed? One can always set the widget theme property directly instead of setting it via plugin options.

maurice-pega commented 7 years ago

The idea was to initialize a widget as follows:

$this->form->field($someModel, 'somePropertyName')->widget(Select2::className(), [
    'data' => $someSelectOptions,
    'options' => [],
    'pluginOptions' => [
       'theme' => \kartik\widgets\Select2::THEME_BOOTSTRAP,
        'allowClear' => true
    ]
])

... rather than overriding the theme property later. I thought this would be an intuitive way to do it, something I expected to be able to do.

kartik-v commented 7 years ago

Not clear... why cannot you achieve the same thing like this:

$this->form->field($someModel, 'somePropertyName')->widget(Select2::className(), [
    'theme' => \kartik\widgets\Select2::THEME_BOOTSTRAP,
    'data' => $someSelectOptions,
    'options' => [],
    'pluginOptions' => [
        'allowClear' => true
    ]
])
maurice-pega commented 7 years ago

Oh, right, I see what you mean. Okay, thanks for your time.