Hi, I’m trying to pass POST variables from my form to my model for processing and error checking however as the value is not part of my model I get an ‘undefined’ error. So:
How can I pass form variables that are not part of my model to the controller
How do I validate these variable using rules() in my model?
simply place in your form controls, but do not use $form->activeXXX, but something like this:
echo CHtml::textField( 'name', $value );
you may access them in action simply: $_POST[‘name’], or Yii::app()->request->postParam( ‘name’, ‘’ );
ad 2)
if those params aren’t part of any model - you must validate them on your own. Rules apply only to model attributes. You may however create another FormModel for this specific form, use its validator and copy parameter to some other model (activerecord for example) after validation succeeds.