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

Update multiple select2 #354

Open juniorlira opened 6 years ago

juniorlira commented 6 years ago

Hi, I'm starting to use YII2, but I'm having an error when updating select2.

my controller `

public function actionUpdate($id) { $model = $this->findModel($id); $alunoModulo = new AlunoModulo(); $alunoModulo = AlunoModulo::find()->where(['id_modulo'=>$id])->All(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('update', [ 'model' => $model, 'alunoModulo'=> $alunoModulo, ]); } } `

My View: <?= $form->field($alunoModulo, 'id_aluno')->widget(Select2::classname(), [ 'data' => ArrayHelper::map(User::find()->where(['role_id'=>3])->all(),'id','username'), 'language' => 'br', 'options' => ['placeholder' => Yii::t('app', 'Select the student ...'),'multiple' => true,], 'pluginOptions' => [ 'allowClear' => true, ], ]);?>

error: Call to a member function isAttributeRequired() on array

thanks

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/54371313-update-multiple-select2?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).
mavelar commented 5 years ago

Same issue here, did you find a solution?