Hi Guys
I have a model with multiple scenarios in the rules.
All rules are included under one of the scenarios, so there are no rules that will ALWAYS be applicable to any scenario.
However, the following model receives no user input and is subsequently not put in any scenario. Strangely the model will not save and constantly throws an exception ‘Model could not be saved.’
$model = user::model()->findByAttributes(array('username'=>'Mark'));
$model->timestamp = time();
if($model->save()){
$this->render('viewSuccess', array('model'=>$model));
}
else{
throw new CHttpException(404,'Model could not be saved.');
}
Even more strangely: If I put the model in a scenario - EVEN A SCENARIO THAT DOES NOT EXIST - then the model saves correctly.
You could therefore argue that "the model needs at least one validation rule to save", but this could not be true, because you can put it in a fake scenario (obviously with no rules) and it will save.
Any thoughts
Thanx