Please help…thanks in advance…I am getting this error:
User has an invalid validation rule. The rule must specify attributes to be validated and the validator name.
I have looked over it several times and can’t find the problem.
I have two forms on the the view, a login form at the top of which the model User is extending CActiveRecord. And a register form at the bottom of which the model HomeRegisterForm extends CFormModel cause I just want to gather the data on this page and carry the data entered (without validation) on this page over the next page which I will then attach the data to the User model and then validate it upon form submission.
Here is my view code for my login form at the top: (User model)
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array('id'=>'login-form',
'enableClientValidation'=>true,
'clientOptions'=>array(
'validateOnSubmit'=>true),
'action'=> Yii::app()->createUrl('site/login'))); ?>
<div class="logInText">
<?php echo $form->label($model_user,'user_email',array('id'=>'email')); ?>
<?php echo $form->label($model_user,'password',array('id'=>'passw')); ?>
</div>
<div class="logInBox">
<?php echo $form->textField($model_user,'user_email',array('id'=>'emailInput', 'class'=>'logInTextBox')) ?>
<?php echo $form->passwordField($model_user,'password',array('id'=>'password', 'class'=>'logInTextBox')) ?>
</div>
<div class="logInSpecial">
<?php echo $form->checkBox($model_user,'user_remembered'); ?>
<?php echo $form->label($model_user,'user_remembered'); ?>
</div>
<div class="logInError">
<?php echo $form->error($model_user,'user_email') ?>
</div>
<div class="logInForgot">
<?php echo Chtml::link('Forgot Password',array('site/forgot'),array('id'=>'forgot')); ?>
</div>
<div id="logInButton">
<?php echo CHtml::submitButton('Log In',array('id'=>'login')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Here is my view code for my register form at the bottom: (HomeRegisterForm model)
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array('id'=>'register-form', 'action'=> Yii::app()->createUrl('site/register'))); ?>
<div id="signUpName">
<?php echo $form->label($model_register,'full_name',array('class'=>'signUpText')); ?>
<?php echo $form->textField($model_register,'full_name', array('class'=>'boxWidth')) ?>
</div>
<div id="signUpEmail">
<?php echo $form->label($model_register,'email',array('class'=>'signUpText')); ?>
<?php echo $form->textField($model_register,'email', array('class'=>'boxWidth')) ?>
</div>
<div id="signUpPass">
<?php echo $form->label($model_register,'password',array('class'=>'signUpText')); ?>
<?php echo $form->passwordField($model_register,'password', array('class'=>'boxWidth')) ?>
</div>
<div id="signUpPassRep">
<?php echo $form->label($model_register,'password_repeat',array('class'=>'signUpText')); ?>
<?php echo $form->passwordField($model_register,'password_repeat', array('class'=>'boxWidth')) ?>
</div>
<div id="signUpButton">
<?php echo CHtml::submitButton('Sign Up!',array('id'=>'signup')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Here is my User model rules code:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('full_name', 'required', 'message'=>'Please enter a value for {attribute}.'),
array('full_name', 'length', 'max'=>70, 'on'=>'register'),
array('user_email', 'unique', 'on'=>'register'),
array('user_email', 'email', 'on'=>'login, register'),
array('user_email', 'required', 'on'=>'register', 'message'=>'Please enter a value for {attribute}.'),
array('user_email', 'exist', 'on'=>'login'),
array('password', 'required', 'on'=>'login'),
array('password', 'length', 'min'=>6,'max'=>16, 'on'=>'register'),
array('password', 'required', 'on'=>'register', 'message'=>'Please enter a value for {attribute}.'),
array('password_repeat', 'on'=>'register'),
array('password','compare','compareAttribute'=>'password_repeat', 'on'=>'register', 'message'=>'Passwords do not match'),
array('password', 'authenticate', 'on'=>'login'),
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
array('user_remembered', 'numerical', 'integerOnly'=>true, 'on'=>'login'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
//array(user_email,'full_name','safe', 'on'=>'search'),
);
}
Here is my HomeRegisterForm model rules code:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('full_name, user_email, password, password_repeat', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
//array(user_email,'full_name','safe', 'on'=>'search'),
);
}
Here is my controller code:
public function actionIndex()
{
$model_register = new HomeRegisterForm;
$model_user = new User('login');
$this->render('index', array('model_user'=>$model_user, 'model_register'=>$model_register));
}
The login form at the top is what I am getting error on and it is point out this line:
(it is also giving the same error for the next line if I remove the current error line)
<?php echo $form->textField($model_user,'user_email',array('id'=>'emailInput', 'class'=>'logInTextBox')) ?>