Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

obtain objects of a class


Reply

2 Posts   711 Views

Avatar
Paco728

13 August 2011 at 6:06pm Community Member, 28 Posts

Hi all.

Would be like to obtain the objects of a particular class only and not all are of the same class

is for use as dropdownfield options.

I'm using DataObject:: get ('class') and this works but selects all classes and I just need this particular

Attached Files
Avatar
swaiba

17 August 2011 at 10:38pm Forum Moderator, 1796 Posts

something like...

$dos = DataObject::get('class');
foreach ($dos as $do) {
if (!in_array($do->ClassName,array('class1','class2'))) {
$dos->remove($do);
}
}
$map = $dos ? $dos->toDropdownMap() : array();
$df = new DropdownField($strFieldName,$strLabel,$map);