Re: find(all) and preppend a third value using Combine

2008-02-07 Thread Josoroma
Thank you. $cities = $this->City->find('all', array('fields' => array('City.id', 'City.name', 'Country.iso2', 'Country.name'), 'order'=>'City.country_id ASC')); $citiesCombine = Set::combine($cities, '{n}.City.id', array('%s - %s', '{n}.Country.iso2', '{n}.City.name'), '{n}.Country.name'); $th

Re: find(all) and preppend a third value using Combine

2008-02-07 Thread AD7six
On Feb 7, 2:06 pm, Josoroma <[EMAIL PROTECTED]> wrote: > Im trying to generate a select list, but before the value Citiy.name i > need to add Country.name like: > > Costa Rica - Heredia > EEUU - New York > > $cities = $this->City->find('all', array('fields' => array('City.id', > 'City.name', 'Co

Re: find(all) and preppend a third value using Combine

2008-02-07 Thread grigri
Sorry, bit of a typo there - where I've got '{n}.Country.name', '{n}.Country.name' [several times] It should of course be '{n}.Country.name', '{n}.City.name' On Feb 7, 1:34 pm, grigri <[EMAIL PROTECTED]> wrote: > To do exactly what you want: > > $citiesCombine = Set::combine($cities, '{n}.City

Re: find(all) and preppend a third value using Combine

2008-02-07 Thread grigri
To do exactly what you want: $citiesCombine = Set::combine($cities, '{n}.City.id', array('%s - %s', '{n}.Country.name', '{n}.Country.name')); But wouldn't you be better off generating option groups based on the country? That's easy too: $citiesCombine = Set::combine($cities, '{n}.City.id', '{n}

find(all) and preppend a third value using Combine

2008-02-07 Thread Josoroma
Im trying to generate a select list, but before the value Citiy.name i need to add Country.name like: Costa Rica - Heredia EEUU - New York $cities = $this->City->find('all', array('fields' => array('City.id', 'City.name', 'Country.name'), 'order'=>'City.country_id ASC')); My question is, how ca