pdm91
(Pramodmahale92)
1
Hiii,
I need to display a [b]message[/b] after saving record in database in controller.
if($model->save())
{
$leavemodel->attributes=$_POST['Clientleave'];
$leavemodel->save();
}
So my question when $leavemodel->save(); successfully executes i need to display messagebox like
"Client has been successfully applied".
jkofsky
(Jkofsky)
2
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.
kiran123
(Sharmakiran71)
3
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'); ?>
<?php
Yii::app()->clientScript->registerScript(
'myHideEffect',
'$(".flash-success").animate({opacity: 1.0}, 3000).fadeOut("slow");',
CClientScript::POS_READY
);
?>
</div>
<?php endif; ?>
Same way you can use error message.
pdm91
(Pramodmahale92)
4
Thanks for the reply it works for me.
But how to increase the size of that message so it can highlight more effectively.
kiran123
(Sharmakiran71)
5
You can customize that message using css tag "div.flash-success" in main.css.