Your states view file is supposed to receive not only the State record but 
also the associated Country record, so that both the State and the Country 
can be displayed in the states view.

The data has to come from the view function in the states controller. In 
that function, the states controller is asking the State model to retrieve 
the State record together with the associated Country record using a 
defined function in the State model, for example named stateById($id).

In the State model, the example function stateById($id) will retrieve the 
State and the associated Country by setting the recursive setting to 1 in 
the find function of the model. Example code:

[code]
$data = $this->find('first', array(
   'recursive' => 1,
   'conditions' => array(
      'State.id' => $id
   ),
));
return $data;
[/code]

Please correct me if I am wrong :)

I would recommend you to take a look at the Containable behaviour to help 
you make it easier to retrieve associated data.
http://book.cakephp.org/2.0/en/core-libraries/behaviors/containable.html

Enjoy, John

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to