2amigos / yii2-multi-select-widget

Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
https://2amigos.us
Other
45 stars 29 forks source link

MultiSelect not work #10

Closed bogdandin closed 7 years ago

bogdandin commented 8 years ago

I replaced this

<?= $form->field($model, 'domeni_carte')->textInput() ?>

with you example;

echo MultiSelect::widget([
    'id'=>"domeni_carte",
    "options" => ['multiple'=>"multiple"], // for the actual multiselect
    'data' => [ 0 => 'super', 2 => 'natural'], // data as array
    'value' => [ 0, 2], // if preselected
    'name' => 'domeni_carte', // name for the form
    "clientOptions" => 
        [
            "includeSelectAllOption" => true,
            'numberDisplayed' => 2
        ], 
]);

And not work to save form... //domeni_carte is simple text

tonydspaniard commented 7 years ago

@bogdandin should be:


echo MultiSelect::widget([
    'model'=> $model,
    'attribute' => "domeni_carte", // should be array of values!
    "options" => ['multiple'=>"multiple"], // for the actual multiselect
    'data' => [ 0 => 'super', 2 => 'natural'], // data as array
    "clientOptions" => 
        [
            "includeSelectAllOption" => true,
            'numberDisplayed' => 2
        ], 
]);