Best place for form messages


What is the best way to create a "Thanks for the submitting the form" message.

And whilst I am at it, I have noticed that we have a "site/error" option in the config file, what is the best way to use this.

You can redirect to a thank you page or flash a message

Here is how to use flash a message

If you use flash message then have a look at this method

I altered it so I don’'t use the CJuiDialog and the title is the div class (error, success) and message is the same.

The site/error in the config is the default error page when you use a throw new CHttpException(400,‘Invalid request. Please do not repeat this request again.’) error;

Flash messages, flash on the page of your choice and the throw new CHttpException will display error message on the site/error page or whatever you have in your config file.

That is the way I understand it. Someone please correct me if I am wrong.







Right ok, so what you saying is that even the "flash" functionality will display the message on the "site/error" page.

Is it wise to throw error exceptions, for things not request related like a message saying "You need to sign in to view this page"?

Sure you can put the code to display a flash message in any view or have a more global all views setup.

I usually use set a flash message and redirect to the page that will correct the problem. Like site/login or back to a the Yii::app()->user->returnUrl;

If there is an error that isn’t fixable like the model won’t save after validation then i go to site/error with a throw exception and that process can be customized with a feedback form or ticket report form.