How To Display Message Box In Controller(Success & Error Both)


  I need to display a [b]message[/b] after saving record in database in controller.






So my question when $leavemodel->save(); successfully executes i need to display messagebox like

"Client has been successfully applied".

Yii::app()->setFlash('success', 'Hey it worked!');

Check the code for the contact form (action & view/form), also look at css for flash-success, etc.

Use below code to set message in controller,

Yii::app()->user->setFlash('success', "Success message");

Use below code to show message in view file, It show flash message for 3 second and than disappear.

<?php if(Yii::app()->user->hasFlash('success')):?>

	<div class="flash-success">

		<?php echo Yii::app()->user->getFlash('success'); ?>




		'$(".flash-success").animate({opacity: 1.0}, 3000).fadeOut("slow");',





<?php endif; ?>

Same way you can use error message.

Thanks for the reply it works for me.

But how to increase the size of that message so it can highlight more effectively.

You can customize that message using css tag "div.flash-success" in main.css.