Thursday, July 21, 2011

How to display hasMany association in the view

I have two modes: Practitioner and Practice

Practitioner hasMany Practice and
Practise Belongs to Practitioner

The practise model has the following fields id,Practitioner_id, Name,
Town etc.
The Practitioner model has the following fields id,Surname, Name, Cell
etc.

In my controller I used a find function:
$Practitioner = $this->Practitioner->find('all');
$this->set(compact('Practitioner'));

In my view I want to display the practitioner name, Surname, cell,
practice name and practice town.

I can display practitioner name, Surname and cell using code like this
$Practitioners['Practitioner']['cell']
But I'm failing to display the corresponding practitioner's practice
name and practice town. I've tried using: $Practitioners['Practice']
['town']; to display town but it looks like nothing gets displayed.

How can I display town? Please help thanks in advance

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate