I have a form displayed in a CJuiDialog and when form is submitted I want the controller action to dynamically update the dialog if there are any validation errors. I assume I need to use an ajaxSubmit button in the form. Could someone provide an example of the ajax button configuration required in the form and the necessary changes required in the controller action to handle displaying the form normally and then updating the form when validation errors are detected?
Following Group form fragment is displayed in a CJuiDialog
public function actionCreate()
{
$model=new Group;
$this->performAjaxValidation($model);
if(isset($_POST['Group']))
{
$model->attributes=$_POST['Group'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
else
// validation error so just update the existing form inside the CJuiDialog
}
// create displays CJuiDialog
$this->render('create',array('model'=>$model));
}