title: Pass Controller Data Array to Element for home.ctp
body: <p>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.</p>
  
  <p>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?</p>
  
  <p>I am getting common error: </p>
  
  <pre><code>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]
  </code></pre>
  
  <p>And here is my code:</p>
  
  <p><i>home.ctp</i></p>
  
  <pre><code>&lt;?php echo $this-&gt;element('search_dental_plans_results'); ?&gt;
  </code></pre>
  
  <p><i>views/elements/search_dental_plans_results.ctp</i></p>
  
  <pre><code>&lt;h2&gt;Plans List&lt;/h2&gt;
  &lt;?php $plans = $this-&gt;requestAction('plans/index'); ?&gt;
  &lt;?php foreach($plans as $plan): ?&gt;
  &lt;ol&gt;
  &lt;li&gt;&lt;?php echo $plan['Plan']['id']; ?&gt;&lt;/li&gt;
  &lt;/ol&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p><i>controllers/plans_controller.php</i></p>
  
  <pre><code>function index() {
      //$plans = $this-&gt;paginate();
      if (isset($this-&gt;params['requested'])) {
          return $plans;
      } else {
          $this-&gt;set('plans', $plans);
      }
  }
  </code></pre>