3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 772 Views |
-
[SOLVED] Convert Enum to Dataobject

28 January 2011 at 11:33am
Hi... I need to convert db enum values to a dataobject so I can loop through them in a template...can anyone help with this??
Enum looks like:'Make' => "Enum('Ford,Great Wall,Holden,Isuzu,Mazda,Mitsubishi,Nissan,Toyota,VW')",
-
Re: [SOLVED] Convert Enum to Dataobject

28 January 2011 at 12:33pm
ok....found it with a bit more searching and mucking around
public function BuildVehicleMenu() {
$doSet = new DataObjectSet();
foreach(singleton('VehicleItem')->dbObject('Make')->enumValues() as $make) {
$doSet->push(new ArrayData(array(
'MakeName' => $make,
'Vehicles' => DataObject::get("VehicleItem","Make = '$make'")
)));
}return $doSet;
}template example:
<% control BuildVehicleMenu %>
$MakeName
<% control Vehicles %>
<a href="$link">$Model</a>
<% end_control %>
<% end_control %>
| 772 Views | ||
|
Page:
1
|
Go to Top |
