Re: controller2 info in controller1/index view
So I added that to the tasks_controller.php:
function index() {
$this->Task->recursive = 1;
$this->set('tasks', $this->paginate());
$projects = $this->Task->Project->find('list'); // HERE
}
To test I added <?php debug($projects); ?> to views/task/index.ctp
but get error:
Notice (8): Undefined variable: projects [APP/views/tasks/index.ctp, line 5]
Just in case here's part of my task.php model:
var $belongsTo = array(
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Project' => array(
'className' => 'Project',
'foreignKey' => 'project_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
On Sat, Dec 18, 2010 at 12:04 AM, cricket <zijn.digital@gmail.com> wrote:
> On Fri, Dec 17, 2010 at 9:26 PM, Steve Mallett <steve.mallett@gmail.com> wrote:
>> Hi,
>>
>> I have two tables in my db. tasks & projects.
>>
>> How do I show a list of all the projects within the tasks/index view?
>> I can echo the project assigned to each task now, but just a simple
>> lists of projects eludes me.
>
> Assuming that Task & Project are associated:
>
> $projects = $this->Task->Project->find('list');
>
> That'll give you an array of 'id' => 'name' (or whatever the displayField is).
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>
--
Steve Mallett
inevitable.cc (the) Inevitable Corp.
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home