Handle Errors

hi I used to handle the error in yii getError().I need to set it in the flash.

this is my contrallor code


Yii::app()->user->setFlash('Error',serialize($usermodel->getErrors()));

to convert array to string I used serialize().

this is my view


<?php

 foreach(Yii::app()->user->getFlashes() as $key => $message) 

echo '<div id="display-success">' . $message . "</div>\n";

  }

?>

bt it gives


a:1:{s:14:"preferred_name";a:1:{i:0;s:31:"Preferred Name cannot be blank.";}}

can I get only the message without others

I mean I need to display only

"Preferred Name cannot be blank."

pls tell How Do I do that.

thanx in advance

Or else is there a way to do it .pls help me with example code

Hi,

May be you can split like this… and send only errors not serialize content…

I hope this will solve your problem

$errors = array();

		foreach (&#036;authItem-&gt;getErrors() as &#036;attribute=&gt;&#036;attributeErrors)


				foreach (&#036;attributeErrors as &#036;error)


					&#036;errors[] = array(


						'attribute'=&gt;&#036;attribute,


						'label'=&gt;&#036;authItem-&gt;getAttributeLabel(&#036;attribute),


						'error'=&gt;&#036;error


					);


			&#036;response = compact('errors');


		}


		header('Content-type: application/json');


		echo CJSON::encode(&#036;response);