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')",
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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')",
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 %>