CFormModel is not populating data

So I’m trying to send out an email, $resend validations check if the email is in the database.

The problem I’m getting is $resend->email is being populated, like its empty or NULL. and the email isn’t being sent out,

however if I hard code the email $signUpEmail->addTo(‘me@google.com’); then it works fine. So somehow $resend->email is not being saved from the form or something.

Here is the code




public function actionVerify()

 {

                $model = new VerifyForm;

                $resend = new ResendForm;

            

            $this->performAjaxValidationTwo(array($model,$resend), 'verify-form');

            

             if(isset($_POST['VerifyForm']))

                {

                 

                $model->attributes=$_POST['VerifyForm'];

                

                $resend->attributes=$_POST['VerifyForm'];

                

                

                         if(!$resend->hasErrors()) 

                         {

                    

                    

                    

                                $signUpEmail = New YiiMailMessage;

                                //$signUpEmail->view = 'signup';

                                //$signUpEmail->setBody(array('model'=>$model), 'text/html');

                                $signUpEmail->setFrom(array('welcome@notesforus.com' => 'Notes For Us'));

                                $signUpEmail->setSubject('Welcome - Notes For Us');

                                $signUpEmail->addTo($resend->email);

                                Yii::app()->mail->send($signUpEmail);

                    

                    

                          }


                $this->render('verify',array(

			'model'=>$model,

                        'resend'=>$resend,

                        

		));

               }

}



Did you declare safe attributes? - http://www.yiiframework.com/doc/guide/1.1/en/form.model#declaring-safe-attributes

I tried it with safe attribute, still doesn’t work. Also tried it without :(


public function rules()

	{

		return array(

			// username and password are required

			// rememberMe needs to be a boolean

			// password needs to be authenticated

                    

                        //array('username', 'finduser'),

			array('email', 'email'),

                        array('email', 'verify'),

                        array('email', 'safe'),

                    

                    

                        

		);

	}

        

        

        

        public function verify($attribute, $params) {

            

            //$this->username = 'mnouh1@binghamton.edu';

            //User::model()->findByUsername($this->username);

            

            $user=User::model()->find(array(

            'select'=>'verify_code, id, verified',

            'condition'=>'username=:username',

            'params'=>array(':username'=>$this->email),

            ));

            

            if($user == NULL) {

                

                

                $this->addError('emailinfo', '✖   I could not find the username');

                

            }

            

            

            

        }

Found the error, this is what happens with lack of sleep haha. Spent like 2 hours looking for the error, running on like 2 hours of sleep :(

$resend->attributes=$_POST[‘VerifyForm’];

should be

$resend->attributes=$_POST[‘ResendForm’];