Hello.
I am confused about how to use checkboxList with multiple models.
Let me explain it better…
I have the Fiscalizacao model and Agenda model.
One Fiscalizacao can have many Agenda, so I have a third model called AgendaFiscalizacao.
My Update Action:
public function actionUpdate($id)
{
$model = $this->findModel($id);
$modelAgenda = AgendaFiscalizacao::findAll(['fiscalizacao_id' => $id]);
if ($model->load(Yii::$app->request->post()) && Model::loadMultiple($modelAgenda, Yii::$app->request->post())) {
// No problem here yet......
}
return $this->render('update', [
'model' => $model,
'modelAgenda' => $modelAgenda
]);
}
My form:
<?= $form->field($modelAgenda, 'agenda_id')->checkboxList(Agenda::combo(), ['class' => 'checkbox']) ?>
<?= $form->field($model, 'bioma_id')->dropDownList(Bioma::combo(), ['prompt' => $prompt]) ?>
<?= $form->field($model, 'nome')->textInput(['maxlength' => true]) ?>
My problem:
My actionCreate is working properly, saving into agenda_fiscalizacao table.
But in actionUpdate i’m receiving this error that prevent the form to load:
Call to a member function formName() on array
What could be wrong?
Thanks and sorry for my bad english!