Forgot about ActiveLabel of Prado!!!
Yii is completely different, there is nothing of similar.
You can try with something like that:
In the controller:
$item->save();
$message='item saved';
if (Yii::app()->request->isAjaxRequest)
{
echo CJSON::encode(
array(
'html'=>$this->renderPartial('view', $data, true),
'flash'=>$message
)
);
exit;
}
else
{
Yii::app()->user->setFlash('success', $message);
$this->render('view', $data, true);
}
this will send your message and your html to your function. The ajax should do something like that:
$.ajax({
type: 'POST',
url: url',
success: function (response){
data=JSON.parse(response);
if (data.status=='success')
{
$('#divToUpdate').html(data.html);
setFlash('success', data.flash);
}
else
{
...
}
}
});
Set flash is a javascript function that displays your flash message. So you should create a div like that:
<div id="#flashSuccess" style="display:none;"></div>
And a js function like this one:
function setFlash(type, message)
{
$('#flashSuccess').html(message);
$('#flashSuccess').fadeIn();
That is a very clean solution.
If you don’t want to implement all this machine in controller and view, you can always roughly write
<script type="text/javascript">
setFlash('success', <?php $message?>);
</script>
in the view that you renderPartial. That will call the setFlash and everithing will work fine.