Thursday, January 27, 2011

Re: HABTM echo value like standard relationship

Let me clarify the relationship a bit more. 

Plan model has state_id field. Each zip belongs to a state.

This inner foreach:
$i = 0;
<?php foreach($plan['State'] as $state): 
 echo $state[$i]; ?>
     <?php endforeach; ?>

Returns:

Array (     [0] => Array         (             [id] => 1             [state_id] => 1             [title] => 97378         )      [1] => Array         (             [id] => 2             [state_id] => 1             [title] => 97128         )

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

No comments: