Hey, all. I wonder can I render two things at the same time. Here is my situation. I created a site that I can create new data, update and delete it through a form. I have lots of forms. Since field areas are the same for create and update form, I found that it will be easier if I create another file(_form.php) in the view folder. In this file I added the ;
<?php $form = ActiveForm::begin(); ?>`
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'abreviation') ?>
<?php ActiveForm::end()?>`
on the other side, In the create.php and update.php file,
I rendered the _form view like this;
<?= $this->render('_form', ['model' => $model]) ?>
Finally, here is my controller:
public function actionCreate()
{
$model = new AdrCountry();
if ($model->load(Yii::$app->request->post()) && $model->validate()){
$model->save();
Yii::$app->session->setFlash('success', ' Başarılı Bir Şekilde Kaydedildi.');
return $this->redirect(Url::to(['index']));
}
return $this->render('create',[
'model' => $model
]);
}
.This works perfect. I want to do same thing for other files. However, I have more than variables defined in the controller and I dont know how to render to thing at the same. For exampe ın other controller ı have $model and $cities variable. And I want to get the cities and model for create and update.Hope I explained myself clearly. THanks for your time and help.