Using Yii's Error Summary

Bonjour,

I would like to be able to use yii’s error summary. I know about the set flash approach, but what that does is it refreshes the screen, thereby making the form the user is filling go away.

Is there a way I could use yii’s error summary to include my custom errors, or use the set flash approach without losing the form which the user may have laboured in typing

Thanks in advance!

Dear Friend

We can do the things in error summary itself.

Let us consider an example.

I have models District and Block.

One district has many blocks.

In creation of a district, I batch create blocks.

I want the errors in individual block forms displayed in error summary of District model.

In District.php I added a virtual property.




class District extends CActiveRecord

{    

public $block;

.......

}



Following is the controller logic inside a foreach loop.




if(!$block->validate(array('name','population','area'))){

       $district->addError('block',$block->fetchErrors(). "on block $i");

       $error=true;

}



What I am doing is fetching errors of all blocks as errors of $block property of district.

Thus we can add anything as an error of an virtual property and can get it displayed in error summary.

Regards.

In addition, if you use clientSideValidation, errors in erroSummary would become visible without page reload - upon clicking submit button and finding validation errors.