Suppose I have two model name User and UserDetail. In UserDetail I put the ID of User when create new User (Foreign key). UserDetail contains the details of user like email, address, ….etc…
How can we update two models with only one view ?

In your yii controller applicaton, create whatever action you want. In here I create ActionCreate()

public function actionCreate()
    $model = new User;
    $modelDetail = new UserDetail;
    if(isset($_POST['User'], $_POST['UserDetail']))

        $valid=$modelDetail->validate() && $valid;

            $modelDetail->user_id = $model->ID;
            // ...redirect to another page
    $this->renderPartial('index',array('model'=>$model, 'modelDetail' => $modelDetail));

In view page

<?php echo CHtml::beginForm(); ?>

    <?php echo CHtml::errorSummary(array($a,$b)); ?>

    <div class="row">
        <?php echo $form->labelEx($model,'username'); ?>
        <?php echo $form->textField($model,'username'); ?>
        <?php echo $form->error($model,'username'); ?>

    <div class="row">
        <?php echo $form->labelEx($modelDetail,'email'); ?>
        <?php echo $form->textField($modelDetail,'email'); ?>
        <?php echo $form->error($modelDetail,'email'); ?>

<?php echo CHtml::endForm(); ?