Re: Different Validation Rule for Different Purpose?

2009-04-30 Thread starkey

You don't need to call model->validates for the login or set any
variables to dummy values.  Here is an article you should read:
http://bakery.cakephp.org/articles/view/simple-form-authentication-in-1-2-x-x


On Apr 29, 9:57 pm, "yangsy...@gmail.com"  wrote:
> Thanks for your answer. I understand the model validation is towards
> the model while not the form now.
>
> I still have some confusion. If at the login form, I only need to
> verify username is not null and do not contain special chars
> (alphaNumeric). What is the right way to do that in CakePHP?
>
> Currently, to use the existing validation infrastructure, before
> validation, I put firstname/lastname to dummy value before call $this-
>
> >model->validates(). Is that workaround make sense?
>
> Best Regards,
> Yang Sun
>
> On Apr 30, 3:32 am, starkey  wrote:
>
> > 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"  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- Hide quoted text -
>
> > - Show quoted text -
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Different Validation Rule for Different Purpose?

2009-04-29 Thread yangsy...@gmail.com

Thanks for your answer. I understand the model validation is towards
the model while not the form now.

I still have some confusion. If at the login form, I only need to
verify username is not null and do not contain special chars
(alphaNumeric). What is the right way to do that in CakePHP?

Currently, to use the existing validation infrastructure, before
validation, I put firstname/lastname to dummy value before call $this-
>model->validates(). Is that workaround make sense?

Best Regards,
Yang Sun

On Apr 30, 3:32 am, starkey  wrote:
> 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"  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- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Different Validation Rule for Different Purpose?

2009-04-29 Thread starkey

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"  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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Different Validation Rule for Different Purpose?

2009-04-29 Thread yangsy...@gmail.com

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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---