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 8995837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:40:21+00:00 2026-06-15T23:40:21+00:00

I want to check if an email/username is unique from a controller. I wrote

  • 0

I want to check if an email/username is unique from a controller. I wrote model validation for isUnique and it works. But I also want a way to use it in controller. Some thing like

$this->User->validates(array('email'=>'someemail@domain.com'));

or

$this->User->checkunique();
//is this the right way to write a different function again.

I know I can use findByEmail from controller and check if it returns empty result set. But I feel that there is a simpler approach or already available way cakephp offers. Please correct me if I am wrong and let me point out the correct approach in this context.

Thanks,
kiran

  • 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-15T23:40:21+00:00Added an answer on June 15, 2026 at 11:40 pm

    Have you had a look at the Cook Book already? There’s a nice explanation on how to do it:

    http://book.cakephp.org/2.0/en/models/data-validation/validating-data-from-the-controller.html

    To sum it up. First set the data to validate:

    $this->User->set($data);
    

    Then validate it and pass a list of fields to restrict validation to if neccessary:

    $this->User->validates(array('fieldList' => array('email')));
    

    Whether you wrap this up in a custom model method is totally up to you, though from a DRY point of view it’s a good idea to do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have done a validation check in my form to check for email,username and
I want to be able to check my email if it equals $e but
I want have an insert query, but before inserting I check whether the username
I have an array I want to check whether the username and Email values
I want to check checkbox like $('#riderCheck').attr('checked','true') on some condition. but the problem is
I have a Django form with a username and email field. I want to
Login username or password. I want customers to login via email on the frontend
How do I check if username or email exists and then put a error
I have register form. I want to check new username that is in db
I want to check whether an SMTP mailbox is available for a given username

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.