Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » New Features

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5
Go to End
Author Topic: 12774 Views
  • UncleCheese
    4085 Posts

    Re: New Features Link to this post

    Just Checked In:

    Many, many, many_many new features!

    Happy new year, DOM users. We'll start off 2010 with several additions to the many_many features of DOM.

    1) Sortable many_many relations

    Drag-and-drop reordering is great, but because the sort is stored on the object itself, you can't have unique sorts for each many_many relationship. Now, with SortableDataObject, you can do this. By taking advantage of the many_many_extraFields property, and a complete overhaul to the query builder, you can now create a sortable many_many relationship like this:

    SortableDataObject::add_sortable_many_many_relation($ClassName, $RelationName);

    Let's look at this a bit further. Often times on my pages, I have a "Callouts" tab that manages content blocks for the sidebar. With a ManyManyDataObjectManager, I can syndicate these across all of my pages easily. In this case, I add:

    SortableDataObject::add_sortable_many_many_relation('Page', 'Callouts');

    Now, the same three callouts that are syndicated to one page, can be on another, with an entirely different sort order!

    Keep in mind that the parameters are the owner class first, and the relationship name second. It is not two class names or two relation names.

    2) Show only associated records

    A lot of times, a many_many relationship is handled elsewhere and we only want to see those records that have been associated with our page. Or, you may have a long list want to filter them down by only the records that are checked off. There is a new permission for ManyManyDataObjectManager named "only_related". This permission is ON by default and will give you a checkbox for showing only the related records.

    This is also important for sorting, because in order to sort a many_many relationship you need to have a view of only the related records. Therefore, when drag-and-drop is enabled on a ManyManyDataObjectManager, the only_related checkbox will be sympathetically checked.

    Here's a use case -- I have hundreds of Testimonials objects that are managed in ModelAdmin and paired with pages there using a MultiSelectField. But in CMSMain, I want to be able to view a given page and see which Testimonials are on that page. I also want the ability to sort them.


    SortableDataObject::add_sortable_many_many_relation('Page', 'Testimonials');

    Page.php (getCMSFields function);

    $f->addFieldToTab("Root.Content.Testimonials", $testimonials = new ManyManyDataObjectManager($this, 'Testimonials', 'Testimonial'));

    This way, users can only edit and sort the records. They cannot change the relationship or add any Testimonials here, because the workflow dictates that such is done through ModelAdmin. Of course, you're welcome to open up the permissions if it suits you. This is just a use case that worked really well for my client.

    3) Bug Fix: ImageDataObjectManager sort issues

    There was a strange and fairly rare bug that would occur when an ImageDOM and any other DOM were present in the same fieldset. The effect of the bug disabled sorting in the ImageDOM. That has been fixed.

    4) Bug Fix: Checkboxes not saving in DOM popups

    When records were added through a DOM popup with checkbox sets, it wasn't until after the record was created that they actually saved. This bug has been resolved.

    5) Improvement: Clicking a row executes the first action (usually edit)

    I had a lot of feedback saying that it was annoying to click the tiny "edit" button on DOM, so I have now given the row a click function that will execute the first action of your actions column. Most of the time this is "edit".

    6) Wide popup available for all DOM instances

    NestedDOM had the requirement of a wider popup window, so I have opened that up as an option on all DOM instances now. You can use setWideMode(true); on any DOM object.

    On the way:

    Confirmed deletes

    Soon, you will be able to run a confirmDelete() function on a DOM object to execute a dialog confirmation before deleting records. There will also be a global setting, for those of you who want it on all the time. The rub with this feature is affording i18n compliance through the javascript alert. I'm hesitant to hardcode the message in English.

    Thanks, everyone, for your continued support of DataObjectManager. As we approach the one-year anniversary of the module, I encourage you to stay tuned for a complete makeover of the UI and a thorough refactoring of the code. That should be well underway by spring.

  • Juanitou
    Community Member
    323 Posts

    Re: New Features Link to this post

    Dear UncleCheese,

    New great features, well explained with clear examples… just thanks!

    Best regards,

  • schellmax
    Community Member
    126 Posts

    Re: New Features Link to this post

    multiple sortable many_many relations: a feature i've been missing in many projects by now. strike.
    thanks again unclecheese!

  • vancouverWill
    Community Member
    121 Posts

    Re: New Features Link to this post

    Hello UncleCheese

    Is there any way to sort out objects within the popup. so for example say I want to create a new menu which would bring up the popup. From within the popup(instance of menu) I add food items(another dataobject) then what if I want to change the sort order? Is this possible?



  • UncleCheese
    4085 Posts

    Re: New Features Link to this post

    Hey, everyone,

    The ManyMany sortable function is broken in 2.3.4. I was foolishly testing in 2.3.3, thinking it wasn't much different, but Silverstripe updated the load_extra_statics() method in DataObjectDecorator, and I need to confer with them to figure out a reconciliation. Thanks for your patience!

  • UncleCheese
    4085 Posts

    Re: New Features Link to this post

    Spoke with Ingo today and confirmed that it is a bug in 2.3.4 that will likely get resolved in 2.4.

    Ticket is here:


  • africansafari
    Community Member
    30 Posts

    Re: New Features Link to this post

    Hi all,

    Just wondering if these new features fix the following bug http://www.silverstripe.org/all-other-modules/show/270194#post270194

    To try and figure out this re-setting problem, I have un-installed most modules and now have userforms, mollom and blog installed.

    Several times a week the userform pagetype and blog entry pagetype re-set back to std pagetype.

    The problem is happening much more regularly these days - 2 to 3 times a week now. I can't keep doing a dev/build to fix!

    When I do a dev/build and re-select the userform pagetype the userform formatting returns. However, when I re-select the blog entry pagetype the formatting does not return and I literally have to re-enter my blog entries again. Not ideal

    Any ideas / suggsetions?



  • UncleCheese
    4085 Posts

    Re: New Features Link to this post

    Is this a bug with userforms or DataObjectManager?

Page: 1 2 3 4 5
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.