Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8972355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:11:59+00:00 2026-06-15T18:11:59+00:00

I have checked cakephp validation for a long time to validate my login form.

  • 0

I have checked cakephp validation for a long time to validate my login form. My problem is when i enter username and password as blank the validation not showing.

Login function in UserController.php contains

 if ($this->request->is('post')) {
            $this->user->set($this->request->data);
            $errors = $this->user->invalidFields(); 

            if ($this->Auth->login()) {
                return $this->redirect($this->Auth->redirect());
            } else {
                $this->Session->setFlash($this->Auth->authError, 'default', array(), 'auth');
                $this->redirect($this->Auth->loginAction);
            }
        } else {

            if ($this->Auth->login()) {
                return $this->redirect($this->Auth->redirect());
            }
        }

My User.php Model contains validator as

 public $validate = array(
        'username' => array(
            'isUnique' => array(
                'rule' => 'isUnique',
                'message' => 'The username has already been taken.',
            ),

            'notEmpty' => array(
                'rule' => 'notEmpty',
                'message' => 'This field cannot be left blank.',
            ),
        ),
        'email' => array(
            'email' => array(
                'rule' => 'email',
                'message' => 'Please provide a valid email address.',
            ),
            'isUnique' => array(
                'rule' => 'isUnique',
                'message' => 'Email address already in use.',
            ),
        ),
        'password' => array(
            'rule' => array('minLength', 6),
            'message' => 'Passwords must be at least 6 characters long.',
        ),
        'current_password' => array(
            'rule' => '_identical',
            ),
        'name' => array(
            'rule' => 'notEmpty',
            'message' => 'This field cannot be left blank.',
        ),
    );

Actually my login form contains only usgername and password. But i have set this validation for userregistration form. The validation worked correctly in registration form but in the case of login the validation not working. Yes io know there is lot of questions posted on this website itself regarding the same issue, but nothing solve my problem, i have tried all the stackoverflow questions. Please Help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:12:00+00:00Added an answer on June 15, 2026 at 6:12 pm

    Validation only occurs when saving, or when you directly call the validation method using:

    $this->Model->validates();
    

    You aren’t getting validation errors because you aren’t actually validating your data. To get validation errors showing you’ll need to do the following:

    if ($this->request->is('post')) {
            $this->User->set($this->request->data);
            if ($this->User->validates()) {
                 echo "This is valid!";
            } else {
                 echo "This is invalid";
                 $errors = $this->User->validationErrors;
            }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have checked this similar question, but the suggestions did not solve my problem:
I have checked the source codes of ASIHTTPRequest and could not make sure which
I am trying to implement form validation using cakephp models. Here are my code
I have checked out the cookbook web site of cakephp that there are four
My problem is that memcache logic inside my cakePHP application is not working on
I have checked several other threads but I am still having a problem. I
I have checked in FireFox Firebug and found that Keypress event is not attached
I'm having a strange issue with my form in CakePHP. I have a series
I have multiple checkboxes in CakePHP's Add/Edit view, created with: echo $this->Form->input('email_warning_chb', array('type'=>'select', 'multiple'=>'checkbox',
I am coding on cakephp 1.3. I have a problem redirecting the page to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.