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

array_combine(): Both parameters should have an equal number of elements #228

Closed nageennayak11 closed 6 years ago

nageennayak11 commented 7 years ago

Prerequisites

I have got the issue when i have update karthik plugin in yii2, Error is :- "array_combine(): Both parameters should have an equal number of elements"

Steps to reproduce the issue

1. 2. 3.

Expected behavior and actual behavior

When I follow those steps, I see...

I was expecting...

Environment

Browsers

Operating System

Libraries

Isolating the problem

Krystian95 commented 6 years ago

I'm having the same issue...

kartik-v commented 6 years ago

please elaborate on the issue with details to reproduce your use case consistently

nageennayak11 commented 6 years ago

First: select2 page jumps to top when clicking drop down list of single at very first time not for multiple.

Second : so i just update my plugin and then get the issue array_combine():

kartik-v commented 6 years ago

Sorry - cannot understand the issue as it lacks details. As mentioned, could you please share steps to clearly reproduce your issue?

You could see the various examples for the usage of the extension on the demos page ... where the issue cannot be reproduced. Compare and let know.

timmy78 commented 5 years ago

It happens when it is a "multiple" input with a string value, not an array.

You have to use it properly like it :

$form->field($model, 'ids[]')->widget(Select2::class, [ //The ids attribute should be an array of keys
            'initValueText' => [1 => 'test'], //Here an array
            'options' => [
                'value' => $model->ids, //Important and should be an array of keys
                'multiple' => true
            ],
            ...
whmemon commented 4 years ago

It Worked ! @nageennayak11 #228

kartik-v commented 4 years ago

Yes a multiple select input obviously expects an array value and outputs an array as well after selection or form submission