public function actionValidateRatePrice() { if (!Yii::app()->request->isAjaxRequest) { $this->thrown; } $attributes = array(); $model = new RateDomestic(); if (isset($_POST['RateDomestic'])) { foreach ($_POST['RateDomestic'] as $key => $value) { foreach ($value as $k => $v) { $attributes[$k] = $v; } } if ($attributes != array()) { $model->attributes = $attributes; $model->service_id = $_POST['service_id']; $model->origin_id = $_POST['service_id']; if ($model->validate()) { echo CJSON::encode(array('success' => true, 'classid' => $key, 'message' => 'sukses')); Yii::app()->end(); } else { $errorMessage = array(); foreach ($model->getErrors() as $errorKey => $errors) { foreach ($errors as $error) { $errorMessage['RatePrice_' . $errorKey . '_em'] = $error; } } echo CJSON::encode(array('success' => false, 'classid' => $key, 'message' => $errorMessage)); Yii::app()->end(); } } } }