Dear Friend
The following is one simple implementation.
I hope this would serve the purpose.
Let us assume that we have model [b]Medico./b
MedicoController.php
public function actionSerialUpdate()
{
$criteria=new CDbCriteria();
$count=Medico::model()->count($criteria);
$pages=new CPagination($count);
$pages->pageSize=1;//JUST GOING TO DISPLAY ONE RECORD.
$pages->applyLimit($criteria);
$model=Medico::model()->find($criteria);
$this->performAjaxValidation($model);//JUST ENSURE THAT THIS METHOD EXISTS INSIDE YOUR CONTROLLER.
if(isset($_POST['Medico']))
{
$model=$this->loadModel($_POST['Medico']['id']);
$model->attributes=$_POST['Medico'];
if($model->save())
{
$this->render('_serialForm',array('model'=>$model,'message'=>"Successfully updated",'pages' => $pages));
Yii::app()->end();
}
}
$this->render('_serialForm', array(
'model' => $model,
'pages' => $pages
));
}
views/medico/_serialForm.php
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'medico-form',
'enableAjaxValidation'=>true, //ENABLED AJAX VALIDATION.
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model);
if(isset($message)) //IF RECORD IS SUCCESSFULLY SAVED,WE ARE GOING TO DISPLAY SUCCESS MESSAGE.
echo CHtml::tag("div",array('class'=>'flash-success'),$message);
?>
<!--WE ARE GOING TO HAVE A HIDDEN FIELD TO COLLECT THE PRIMARY KEY.-->
<div class="row">
<?php echo $form->hiddenField($model,'id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>64)); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'age'); ?>
<?php echo $form->textField($model,'age'); ?>
<?php echo $form->error($model,'age'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'sex'); ?>
<?php echo $form->textField($model,'sex',array('size'=>10,'maxlength'=>10)); ?>
<?php echo $form->error($model,'sex'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'native'); ?>
<?php echo $form->textField($model,'native',array('size'=>60,'maxlength'=>64)); ?>
<?php echo $form->error($model,'native'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<?php $this->widget('CLinkPager', array(
'pages' => $pages, //WE ARE GOING TO USE CLINKPAGER TO NAVIGATE ACROSS MANY RECORDS.
)) ?>
I am using CActiveForm.
I have not tested including a dialog box inside the form.
If you are finding any difficulty in inducting a dialog box,let me know.
Regards.