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

  • Home
  • SEARCH
  • 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 8132927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:27:52+00:00 2026-06-06T09:27:52+00:00

I am working on a feature to edit all the items in the table.

  • 0

I am working on a feature to edit all the items in the table.

Here is my edit action from my controller:

public function editAll()
    {
        $this->set('isEditAllValid', false);
        $this->set('editAllValidationErrors', false);

        if ($this->request->is('post'))
        {
            $this->LocalClock->table = 'local_clocks';
            $this->LocalClock->getDataSource()->tableFields['local_clocks'] = array( "id", "name", "auto_offset", "utc_offset_sec", "in_month", "in_week", "in_day", "in_hour", "out_month", "out_week", "out_day", "out_hour", "offset_sec");
            $this->set('localClocksEntries', $this->LocalClock->find('all'));
            if ($this->LocalClock->save($this->request->data))
            {
                foreach($localClocksEntries as $LocalClock)
                {
                    $this->set('LocalClock', $this->request->data);
                    $this->LocalClock->save($LocalClock);
                    $this->set('isEditAllValid', true);
                    $this->set('editAllValidationErrors', false);
                }
            }
            else
            {
                $this->set('isEditAllValid', false);
                $this->set('editAllValidationErrors', true);
            }
        }
    }

What I am doing in the code is, set some boolean variables to false (validation stuff), then if the action is a post grab the local clocks table and insert that into a variable for storage. Then loop through that variable and save the data that was posted to each item in the table.

I don’t know why but I am getting2 errors when trying to edit all.

Notice (8): Undefined variable: localClocksEntries [APP/Controller/LocalClocksController.php, line 158]
Warning (2): Invalid argument supplied for foreach() [APP/Controller/LocalClocksController.php, line 158]

Basically I just want to loop through every row in the table and change the contents to what the user entered in the form.

  • 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-06T09:27:53+00:00Added an answer on June 6, 2026 at 9:27 am
    $this->set('localClocksEntries', $this->LocalClock->find('all'));
    

    This sets a variable for the view. It does not create that variable in the current scope. So the variable $localClocksEntries does not exist in foreach ($localClocksEntries .... If you want to use the variable in the current scope and pass it on to the view, do:

    $localClocksEntries = $this->LocalClock->find('all');
    $this->set('localClocksEntries', $localClocksEntries);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Git I can do this: 1. Start working on new feature: $ git
I'm working on a search feature for my application, I want to search all
I am trying to get FileUpload feature working with Icefaces ace:fileEntry but my fileUploadListener
I have installed Eclipse Indigo and the auto-complete feature is working normally in the
I am working on wireframe for new feature in our application. One of the
I am working on an indexing/searching feature of a site. The indexing runs every
If I am working in multiple branches on a single feature, I use git
I'm working on what should (hopefully) be a small feature for a .NET software
Context: I'm working on master adding a simple feature. After a few minutes I
I am working on a project using the Orb feature detector in OpenCV 2.3.1

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.