Wednesday, May 2, 2012

Giving context to a select field?

So, I have a Location Model that is using the tree behavior. Level 1
is Countries, their children are Regions. The Regions children are
cities... So I need to give some context to the results in the select
menu since there are several cities with the name "Portland" for
example. Is it Portland, Oregon or Portland, Maine? I know you can
give context to select fields by giving it an array with sub arrays.
As such, this is what I want to get from my database when I ask for
all the cities:

array('Oregon'=>array(42=>'Salem',33=>'Portland', 50=>'Ashland'),
'Maine'=>array(86=>'Portland', 103=>'Agusta'));

I can make that with a bit of post processing after the data is
retrieved from the DB, but is there a way to get that kind of format
straight from the query? Thanks.

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