Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Collecting Cactiveform Errors On Server-Side

$
0
0
Hello,

I have a `CActiveForm` with this summary:

	.
	.
	.
	'id'='email-form',
	'enableAjaxValidation`=>true,
	'clientOptions' => array('validateOnSubmit'=>true),
	.
	.
	.


Now i intend collect form Errors in Server-Side and sent it via json object to the client. in Client-Side there
is and Jquery function that parse the json object(form Errors) and set data to errorSummary and at last
shows the errorSummary of form.

i have done it without any problem, my question is what following functions don't collect form Errors:

	protected function getErrorSummary($model)
	{
    	if(isset($_POST['ajax']) && $_POST['ajax']==='email-form'){
        	$errors=CActiveForm::validate($model);
        	if($errors !== '[]')
            	Yii::app()->end($errors);
    	}
	}


But following collect form Errors:

	protected function getErrorSummary($model)
	{
        	$errors=CActiveForm::validate($model);
        	if($errors !== '[]')
            	Yii::app()->end($errors);
	}


notice that both functions truly acts on validateOnChange.

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>