suitable to pass to FormHelper for select options with optgroup
labels. Set::combine has gotten me almost there but not quite.
Here's the data:
Array
(
[0] => Array
(
[id] => 1
[iso_code] => US
[name] => United States
[regions] => Array
(
[0] => Array
(
[id] => 4
[country_id] => 1
[iso_code] => AZ
[name] => Arizona
)
[1] => Array
(
[id] => 7
[country_id] => 1
[iso_code] => CA
[name] => California
)
...
[30] => Array
(
[id] => 63
[country_id] => 1
[iso_code] => WI
[name] => Wisconsin
)
)
)
[1] => Array
(
[id] => 2
[iso_code] => CA
[name] => Canada
[regions] => Array
(
[0] => Array
(
[id] => 6
[country_id] => 2
[iso_code] => BC
[name] => British Columbia
)
...
I tried:
$options = Set::combine(
$data,
'{n}.name',
'{n}.regions.{n}.name'
);
This creates:
Array
(
[United States] => Array
(
[0] => Arizona
[1] => California
[2] => Colorado
...
)
[Canada] => Array
(
[0] => British Columbia
...
What I require:
Array
(
[United States] => Array
(
[AZ] => Arizona
[CA] => California
[CO] => Colorado
...
)
[Canada] => Array
(
[BC] => British Columbia
...
Can anyone think of a way to do that with Set?
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
To unsubscribe from this group, send email to cake-php+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
No comments:
Post a Comment