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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:03:15+00:00 2026-05-18T22:03:15+00:00

Hi I have been trying to access the validation rules of an associated model

  • 0

Hi I have been trying to access the validation rules of an associated model from my main controller. It doesn’t seem to be working and I haven’t been able to find any reference about this. Here is what I am trying to do:

User Controller snip:

$this->User->TalentProfile->set( $this->data );
if ($this->User->TalentProfile->validates()) {
    //it always validates and doesn't seem to see model's validation rules
}

TalentProfile Model snip:

var $validate = array (
        'first_name' => array(
            'maxLength' => array(
                    'rule' => array('maxLength', 20),  
                    'message' => 'Can not be longer than 20 characters.',
                    'last' => true
            ),
            'first_name_not_empty' => array(
                    'rule' => 'notEmpty',
                    'message' => 'This field is required',
                    'last' => true
            ),
        ),
);

I have also tried rewrapping the array my thought being that the model name could be screwing with the validation:

$this->User->TalentProfile->set( array('TalentProfile',$this->data) ) );

I have also tried this hoping but still same results:

$this->loadModel('TalentProfile');
$this->TalentProfile->set( $this->data) );

There is something I am missing. Please help! Thanks

EDIT:

I tried to save the form data which is giving me blanks in the SQL. I think this might be a simpler problem than I thought.

  • 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-05-18T22:03:16+00:00Added an answer on May 18, 2026 at 10:03 pm

    By setting the $validate array in the TalentProfile model, you require data to be of the form:

    Array(
        [TalentProfile] => Array(
            [first_name] =>
        )
    )
    

    A little explanation on how this works:

    In the call $this->User->TalentProfile->validates() and $this->TalentProfile->validates() you are using the validation methods in the TalentProfile model. This means that CakePHP is going to validate your input data against the validation rules in that model, so it expects the TalentProfile key to be set in the array (but dies down quietly if it’s not).

    In your $validates array, you have set up validation rules for a key called first_name. CakePHP takes this key as a field name that is being input from a form.

    Right now, you are taking inputs as fname instead of first_name. Your inputs are also associated with the User model, and not TalentProfile.

    If you explain further what you’re trying to do with your form, I can be of more help.

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

Sidebar

Related Questions

I have been trying to get it working for hours with little success. From
I have been trying to access some data from a website. I have been
I have been trying to access an xmlType column-table from my java application the
I have been trying to access data from another site by ajax but failed.
I have been trying to understand why I cannot access these links from my
I have been trying to access MySQL routines from my Spring project using SimpleJdbcDaoSupport.
I have been trying to access the below code DECLARE N_DEPTNO DEPT.DEPTNO %TYPE :=&DEPT_NUM;
I've been trying to use 'import poplib' to access gmail, since I have Pop
I have been trying to access/parse the message object found in the JSON results
I have been trying to access a .NET Assembly that I have created in

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.