/** * Creates a new PersonItem model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new PersonItem(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { $people = \yii\helpers\ArrayHelper::map(Person::find()->asArray()->all(), 'id', 'lastname'); $items = \yii\helpers\ArrayHelper::map(Item::find()->asArray()->all(), 'id', 'name'); return $this->render('create', ['model' => $model, 'items' => $items, 'people' => $people]); } }