THANK YOU!  That was exactly the problem.  I was using notEmpty, AND
required => true.

Also, thanks for the tip on using a single controller action!

On Sep 20, 3:03 am, "euromark (munich)" <[email protected]>
wrote:
> actually thats not quite how it is supposed to be done
>
> you only need one validate_ajax method or whatever
> if you set up your rules according to the cookbook (and without using
> "required"=>true!!!)
> you are able to pass only the form vars necessary for the current
> validation - inside your single ajax action
>
> it will then only validate those passed (like "username" for 
> $this->data[User][username])
>
> all other validation rules are not touched!
>
> the rule "notEmpty" has nothing to do with this
> the rule itself is only triggered if the corresponding field exists -
> and as soon as this happens, the field is supposed to be "notEmpty"
>
> this is actually something that is NOWHERE in the documentation
> and therefore hard to understand for most beginners - there are lots
> of errors made here due to false assumptions..
>
> and as for the "required" rule mentioned above:
> this means there is no way the validation will pass if this field is
> not present - especially without existing corresponding fields those
> rules will trigger errors and should not be used in most cases.
> Most certainly not if you plan to use such "partial" validation/insert/
> edit stuff.
> as a matter of fact i have never found a single reason to use them...
> as they restrict your options more than beeing helpful
>
> On 20 Sep., 03:31, "young.steveo" <[email protected]> wrote:
>
>
>
> > First, a big "Thank You" to this group, it's helped me a lot by
> > reading posts here.
>
> > I'm using ajax to pre-validate a form while the user types data into
> > the form's fields.  So, if the user types a username that is too
> > short, or already in use, etc., they are notified by the script as
> > they type.  You know the drill.  ;)
>
> > I'm using cakePHP's model validation to test if the data is valid.  If
> > I include only one field in the $validate array, for exaple:
> > 'username', and then I put the following logic in my controller:
>
> > $this->MyModel->set($this->data);
> > if ($this->MyModel->validates()) {
> >   $this->render('validate', 'ajax');
> > else {
> >   $this->render('invalidate', 'ajax');
>
> > }
>
> > everything works fine.  However, if I include muliple fields in the
> > model's $validate array, like password, email, etc., then when I try
> > to validate only the username (the user has not typed anything into
> > the password or email field yet), it does not validate (presumably
> > because the logic I have written for validating a password states that
> > the password field cannot be empty), and the code renders the
> > invalidate.ctp.
>
> > I'm seperating the controller actions into username_validate,
> > password_validate, etc. for the ajax calls, so how do I get cakephp to
> > only check if the username is valid, when password and email data is
> > not present?- 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to