Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Problem storing multiple items from a DataObject

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: 356 Views
  • woodb2
    Community Member
    48 Posts

    Problem storing multiple items from a DataObject Link to this post

    I have a couple of DataObjects. The main one is called Enhancement (for storing enhancement requests). Enhancement has a $has_one to $has_many to a dataobject StatusLevels (just an object where the users can manage the different status levels that enhancements can be. This all works great (using modeladmin for everything).

    The problem occurs with my Project dataobject. I want to be able to assign multiple enhancements to a project. I've tried using DataObjectManager, AsmselectField and ItemSelectFied, but each has it's drawbacks and none of them work how I need.

    AsmselectField is my favorite, but here's what's happening:

    I'm creating a dropdownfield with the title from Enhancement. I can get this to work, but I only want enhancements that statuslevel isn't completed. I can add enhancements, but soon as I change their status in the Enhancement Object to completed, they no longer appear in my pulldown (which is exactly like I want), but any ones already select are removed from my list. It filters out the completed ones from my asmselect field list. Which I don't want it to do.

       $enhancements = DataObject::get('Enhancement', 'StatusLevelsID != 2');
       if ($enhancements) {
          $map = $enhancements->toDropdownMap('ID', 'Title');
       $fields->addFieldToTab("Root.ProjectEnhancements", new AsmselectField('Enhancements', 'Enhancement', $map));

    This field would working great if I showed every enhancement in the list, but I really want to filter it out so that you can't select enhancements that are already completed. Is there a way to not have it filter out the selected list too?


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.