scenario validation rules showing null

model object is as

UserChangePassword Object
(
    [oldPassword] => 
    [password] => 
    [verifyPassword] => 
    [_errors:CModel:private] => Array
        (
        )

    [_validators:CModel:private] => 
    [_scenario:CModel:private] => change
    [_e:CComponent:private] => 
    [_m:CComponent:private] => 
)

model rules are

array('oldPassword, password, verifyPassword', 'required','on' => 'change'),
            array('oldPassword, password, verifyPassword', 'length', 'max'=>128, 'min' => 4,'on' => 'change','message' => Yii::t('recovery',"Incorrect password (minimal length 4 symbols).")),
            array('verifyPassword', 'compare', 'compareAttribute'=>'password','on' => 'change','message' => Yii::t('recovery',"Retype Password is incorrect.")),
            array('oldPassword', 'verifyOldPassword','on' => 'change'),

controller create model as

$passwordForm = new UserChangePassword('change');
$this->renderPartial('_password', array('form' => $passwordForm));

Please help me ?

Answers


rules method has to return array of validation rules. Just like below:

public function rules()
{
    return array(
        // validation rules go here
    );
}

if it doesn't (array is only declared and return keyword is missed) - this can cause the problem.


Need Your Help

Where should the validation be, in the MVC layer or in the business engine?

spring validation spring-mvc design-patterns rpc

A web application backend coded in Spring makes remote procedure calls to a "business engine" which performs intensive calculations.

Update content depending on string in view model

c# asp.net-mvc asp.net-mvc-4 asp.net-mvc-viewmodel

I am running an MVC application, which have a view model like this: