another scenario issue

im working quite a while now with yii but there are still things i don't get.

For example:

had a form and changed it a bit. after the change it won't work anymore.

i found out that the error depends on the validation, so i played a bit with the result that everything is fine as long as i leave the brackets empty.

		


                $asd=new Kunden;


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


		{


			$asd->attributes=$_POST['Kunden'];


			if($asd->validate('reg'))


			{


				if($asd->save())


				{


works:

if($asd->validate())

works not:

if($asd->validate('reg'))

does somebody know why?

this is the modelcode:

	public function rules()


	{


		return array(


			// REGISTRIERUNG


			array('vorname, zuname, email', 'required', 'on'=>'reg'),


			// verifyCode needs to be entered correctly


			array('verifyCode', 'captcha', 'allowEmpty'=>!extension_loaded('gd'), 'on'=>'reg'),


			// PASSWORT VERGESSEN


			array('email', 'required', 'on' => 'recover'),


			// PROFILE


			array('pwd', 'compare', 'on'=>'mitpwd'),


			array('email', 'unique', 'on'=>'profile'),


			// IMMER


			array('user, pwd', 'length', 'max'=>35, 'min'=>3),


			array('email', 'email'),


		);


	}


	


	public function safeAttributes()


	{


	return array('vorname', 'zuname', 'user', 'status', 'verifyCode', 'personalpwd', 'email', 'homepage', 'tel', 'firma', 'str', 'num', 'ort', 'plz');


	    return array(parent::safeAttributes(), 'reg' => 'vorname, zuname, user, pwd, pwd_repeat, ts, personalpwd, email, homepage, tel, firma, str, num, ort, plz',);


	    return array(parent::safeAttributes(), 'mitpwd' => 'user, pwd, pwd_repeat, email, homepage, tel, firma, str, num, ort, plz',);


	    return array(parent::safeAttributes(), 'ohnepwd' => 'user, email, homepage, tel, firma, str, num, ort, plz',);


	}


When you use validate('reg'), only those rules whose 'on' option is empty or contains 'reg' will be applied.

If you call validate(), only those rules with empty 'on' option will be applied.

i know that… thank you.

its just if i leave it empty its fine otherwise it stops working at the point

if($model->validate(‘bla’))

everything after that will be ignored.

no errer no nothin'

??????

What do you mean "it won't work"? It doesn't validate as expected, the page is blank, no error message, or what? Did you turn on PHP error display?

this is the controller action. I put a comment behind the line which includes the error appearing

<?


		$asd=new Kunden;


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


		{


			$asd->attributes=$_POST['Kunden'];


			if($asd->validate())


			{


				if($asd->save())


				{


					...


					Yii::app()->user->setFlash('reg','<p>success</p>');


					$this->render('index1',array('success'=>$success, 'kunden'=>$asd));


					}


					Yii::app()->user->setFlash('reg','error 1');


					$this->render('index1');


					die();


				}


				Yii::app()->user->setFlash('reg','error 2');


				$this->render('index1');


				die();


			}


			Yii::app()->user->setFlash('reg','error 3'); // this error appears when i set a scenario


			$this->render('index1');


			die();


		}


?>

Do you definetly have a CHtml::errorSummary() in your form so you can see which validation failes ?

Try doing a var dump on $asd->errors.