In my project i am using Gii to generate my model.Here by default i am getting some rues depends on my
database table structure.
But I am facing so many validation problem because of this default rules.
For example i have one sign up form and i am using user model…there i need almost all fields as mandatory… same time i have some other forms like change password, or update profile etc… but here I am using some few fields as mandatory.
If i write a scenario for these forms also while submitting the form which validating those fields which i am not using this forms why because the default rules.Here Please advise me how i can handle this problem like a professional way…
you can use something looklike this
// name, email, subject and body are required
array('change password,password', 'required','on'=>'update'),
array('password', 'required', 'on'=>'update'),
array('password_repeat', 'compare', 'compareAttribute'=>'password', 'on'=>'update'),
you can use this
$model = new Users('create');
and record update
$model = new Users('update');
more reference please see it…
i hope it’s works…
thanks for your quick response…
the same way i done but apart from that i kept the default rules which Gii provided.
So maybe there i did the mistake.Please correct me if i wrong…