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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:28:26+00:00 2026-05-20T01:28:26+00:00

According to the manual and my code, this should be working perfect, but it

  • 0

According to the manual and my code, this should be working perfect, but it is not. I’ve been messing around with this code for too long, and I wanted anyone to look at it to see if there is something I cannot see.

I am trying to call the index() action of my plans controller passing an array of data to the element for display. Anyone know why this is not working?

I am getting common error:

Notice (8): Undefined variable: 
plans [APP/views/elements/search_dental_plans_results.ctp,  line 12]
Warning (2): Invalid argument supplied for foreach()
[APP/views/elements/search_dental_plans_results.ctp, line 12]

And here is my code:

home.ctp

<?php echo $this->element('search_dental_plans_results'); ?>

views/elements/search_dental_plans_results.ctp

<h2>Plans List</h2>
<?php $plans = $this->requestAction('plans/index'); ?>
<?php foreach($plans as $plan): ?>
<ol>
<li><?php echo $plan['Plan']['id']; ?></li>
</ol>
<?php endforeach; ?>

controllers/plans_controller.php

function index() {
    //$plans = $this->paginate();
    if (isset($this->params['requested'])) {
        return $plans;
    } else {
        $this->set('plans', $plans);
    }
}
  • 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-20T01:28:27+00:00Added an answer on May 20, 2026 at 1:28 am

    I SOLVED this in an “unexpected” way (at least according to the manual this method was not noted):

    element

    …

    $planDetails = $this->requestAction('/planDetails/pd_list');
    foreach ($planDetails as $planDetail) :
    

    …

    controller logic

    function pd_list() {
    return $this->PlanDetail->find('all');
    }
    

    Works like a charm : ) although I am going to use a containable and cache control when done, but at least its working as expected.

    Not too holy and problem solved : )

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

Sidebar

Related Questions

According to the PHP manual , in order to make code more portable, they
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when
According to the Doctrine manual I should be able to reference an attribute of
According to the manual , git dcommit will create a revision in SVN for
According to this discussion , the iphone agreement says that it doesn't allow loading
According to select name from system_privilege_map System has been granted: SELECT ANY TABLE ...and
According to what I have found so far, I can use the following code:
According to the answers to this question, I cannot embed a file version in
According to the PHP Manual , calling array_map with a NULL callback causes it
Hi this is my code and it returns You have an error in your

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.