Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » obtain objects of a class

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

Page: 1
Go to End
Author Topic: 706 Views
  • Paco728
    Community Member
    28 Posts

    obtain objects of a class Link to this post

    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
  • swaiba
    Forum Moderator
    1792 Posts

    Re: obtain objects of a class Link to this post

    something like...

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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.