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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:04:03+00:00 2026-05-28T07:04:03+00:00

I have to manipulate the data posted before saving it. $this->data is an array

  • 0

I have to manipulate the data posted before saving it.
$this->data is an array like this

Array
(
    [Presence] => Array
        (
            [Month] => 02
            [Year] => 2012
            [0] => Array
                (
                    [day] => 1
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [1] => Array
                (
                    [day] => 2
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [2] => Array
                (
                    [day] => 3
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [3] => Array
                (
                    [day] => 4
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [4] => Array
                (
                    [note] => 
                )

            [5] => Array
                (
                    [note] => 
                )

            [6] => Array
                (
                    [day] => 7
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [7] => Array
                (
                    [day] => 8
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [8] => Array
                (
                    [day] => 9
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [9] => Array
                (
                    [day] => 10
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [10] => Array
                (
                    [day] => 11
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [11] => Array
                (
                    [note] => 
                )

            [12] => Array
                (
                    [note] => 
                )

            [13] => Array
                (
                    [day] => 14
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [14] => Array
                (
                    [day] => 15
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [15] => Array
                (
                    [day] => 16
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [16] => Array
                (
                    [day] => 17
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [17] => Array
                (
                    [day] => 18
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [18] => Array
                (
                    [note] => 
                )

            [19] => Array
                (
                    [note] => 
                )

            [20] => Array
                (
                    [day] => 21
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [21] => Array
                (
                    [day] => 22
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [22] => Array
                (
                    [day] => 23
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [23] => Array
                (
                    [day] => 24
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [24] => Array
                (
                    [day] => 25
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [25] => Array
                (
                    [note] => 
                )

            [26] => Array
                (
                    [note] => 
                )

            [27] => Array
                (
                    [day] => 28
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [28] => Array
                (
                    [day] => 29
                    [presenza] => 1
                    [time_in] => 09:00
                    [time_out] => 18:00
                    [pausa] => 01:00
                    [hours] => 08:00
                    [client_id] => 4
                    [note] => 
                )

            [user_id] => 3
        )

)

and I have to modify the day and insert the user_id in every “sub-array”.

But when i call, just for debugging, debug($this->data) on my beforeSave() the result is an empty array and I can’t do nothing.

  • 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-28T07:04:04+00:00Added an answer on May 28, 2026 at 7:04 am

    The beforeSave method should only return either true or false to tell the save function if it may continue, so you can only put logic there, but not affect the data itself.

    To modify the data, just (re)-set it in your controller function before calling the save function, like:

    foreach($this->data['Presence'] as $key => $data) {
        if(is_array($key)) {
            // This should be a sub-array
            $this->data['Presence'][$key]['day'] = 1; // Set your 'new' day here
            $this->data['Presence'][$key]['user_id'] = 1337; // Set your user id here
        }
    }
    
    // Then, afterwards, save the adjusted data array
    $this->Presence->save($this->data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a read/write stream to read a buffer, manipulate the data(like adding
I have got a couple of functions that manipulate data in an array, for
I wish to manipulate data on a very low level. Therefore I have a
We have a SQL server database. To manipulate the data non-programmatically, I can use
I have situation where a user can manipulate a large set of data (presented
I've got some financial data to store and manipulate. Let's say I have 2
I have a 320x480 PNG that I would like to texture map/manipulate on the
I have a Excel CSV files with employee records in them. Something like this:
If you have to retrieve data from a database and bring this dataset to
This is a problem i have with data that i receive from a library

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.