Pass the data in the Element array

 

<?php echo $this->Element('search_dental_plans_results', array( 'plans' =>
$plans, // optional to cache the element 'cache' => true / false /
duration)); ?>

 

 

From: OldWest [mailto:[email protected]] 
Sent: Thursday, February 03, 2011 7:01 PM
To: [email protected]
Subject: Pass Controller Data Array to Element for home.ctp

 

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);


    }


}

-- 
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help
others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to