Wednesday, April 29, 2009

Re: Different Validation Rule for Different Purpose?

I hope this answers your question:

The validation is for the model (the database table) and not the
form. The error messages appear on the form which may make you think
the validation rules are validating the data in the form... but it
isn't. The validation rules check the data before an insert or update
to the table.

Therefore, you only need the one rule to check the first/last/user
names and the password. When someone logs in you do a model->find()
which doesn't go through the validation rules.

Shawn


On Apr 29, 4:25 am, "yangsy...@gmail.com" <yangsy...@gmail.com> wrote:
> Hi,
>
> I am not sure whether CakePHP suport different validation rules for
> the same model.
>
> My problem is to validate user.
> In the registration form, I have to validate username/password/
> firstname/lastname to be the correct value.
> But to the login form, I only need user to input username/password.
>
> If I specified the validation rules for the registration form in the
> user model. Then in the login form, I will always got error result
> because it is still checking rules for firstname/lastname.
>
> Does CakePHP provide some standard way to solve that? So I can say I
> want check 4 fields when do registration and only check 2 fields when
> do login.
>
> Thanks for your help.
>
> Best Regards,
> Yang Sun
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: