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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:31:31+00:00 2026-06-02T00:31:31+00:00

Mycakephp version is 2.1.1. i am trying to save the associated model manually using

  • 0

Mycakephp version is 2.1.1.

i am trying to save the associated model manually using saveAll() function

Model

  • Employee HasOne Address
  • Employee Belongs to Department

so table

employees(first_name,last_name,age,sex,department_id)

addresses(first_line,second_line,city,state,employee_id)

now employee creation add.ctp has a form which receives input for employee and address

i know

$this->Employee->saveAll($this->request->data);

this will save the models but
i want to save the association manually

i was going through the official cakephp document here and i have tried something like this

        $this->Employee->saveAll($data, array(
            'fieldList' => array(
            'Employee' => array('first_name','last_name','age','sex','department_id'),
            'Department' => array('first_line', 'second_line','city','state','employee_id')
            )
        ));

it is not working , and throws following errors

Notice (8): Undefined variable: data
[APP\Controller\EmployeesController.php, line 118]

Warning (2): array_keys() expects parameter 1 to be array, null given
[CORE\Cake\Model\Model.php, line 1996]

i am cakephp beginner. please help me.

$this->request->data: Array

(

[Employee] => Array
    (
        [first_name] => Jack
        [last_name] => Robert
        [age] => 32
        [sex] => 0
        [Department] => Development
    )

[Address] => Array
    (
        [first_line] => HSR Layout
        [second_line] => 1st Cross
        [city] => Najem
        [state] => Barel
    )

[Department] => Array
    (
        [id] => 3
    )

)

  • 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-02T00:31:34+00:00Added an answer on June 2, 2026 at 12:31 am

    After doing some research i have found it.

           $data = array(
             'Employee' => array(
             'first_name' => $this->request->data['Employee']['first_name'],
             'last_name'=>$this->request->data['Employee']['last_name'],
             'age'=>$this->request->data['Employee']['age'],
             'sex'=>$this->request->data['Employee']['sex'],
             'department_id'=>$this->request->data['Department']['id']
            ),
             'Adress' => array(
             'first_line' => $this->request->data['Adress']['first_line'],
             'second_line'=>$this->request->data['Adress']['second_line'],
             'city'=>$this->request->data['Adress']['city'],
             'state'=>$this->request->data['Adress']['state']
            )
    
        );
    
    
                $this->Employee->saveAll($data, array('deep' => true))
    

    this will do it.

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

Sidebar

Related Questions

I am using ajax with jQuery in my cakePHP application. and my javascript function
I am trying to implement facebook Connect to my cakephp Application. i am using
I use git as my primary version control system, and have recently started using
In my CakePHP view, I call method in controller, using jQuery: function placeSensors(nk) {
In my CakePHP application, By using cake.bat i created POT files and by using
In my CakePHP 1.2.5 app, I have a Profile model that belongsTo a User
In my CakePHP-1.2 application, I am using the date format 01-Jan-2012 Which date validation
I am trying to implement CKEditor in my CakePHP app admin section with a
Please have a look at this validation array in my cakephp app for model
I am looking to build a reset password function in my CakePHP app, and

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.