How to add data into two table using one form in yii2

How to add data into two table using one form in yii2 using one controllers by instatiating on model class into another controller like what we were doing in YIi 1.*

Exampel in Yii1

public function actionCreate()

{


    $model = new User();


    $userGroup = new UserGroup;


    if ($model->load(Yii::$app->request->post()) && $model->save()) {


        return $this->redirect(['view', 'id' => $model->id]);


    } else {


        return $this->render('create', [


            'model' => $model,'userGroup'=>$userGroup,


        ]);


    }


}

then I instatiate my UserGroup class in UserController and renderPartial it in my User form like

<?= $form->field($userGroup,‘user_id’)->textInput([‘maxlength’ => true])->label(’’) ?>

it give error msg

Undefined variable: userGroup