public function actionSignUp() { $data = $_POST; if (isset($data['zip'])) { $data['zip'] = str_replace(' ', '', $data['zip']); } $validator = new signUpModel(); $zipValidator = new signUpZipModel(); $validator->setAttributes($data); $zipValidator->setAttributes($data); $zipValidator->setAttribute('zip', str_replace(' ', '', $zipValidator->getAttributeLabel('zip'))); $result = $validator->validate() && $zipValidator->validate() ? $result = array('validate' => true) : array('validate' => false, 'errors' => array_merge($zipValidator->getErrors(), $validator->getErrors())); echo json_encode($result); YII::app()->end(); }
/** * * @todo refactoring this * @param type $data * @return array */ protected function signUpValidation($data) { $errors = array(); $model = new signUpModel(); //$zipModel = new signUpZipModel(); $model->setAttributes($data); //$zipModel->setAttributes($data); $model->validate(); //$zipModel->validate(); $errors = array_merge($model->getErrors()); return $errors; }