Jump to:

7938 Posts in 1540 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » SortOrder increment before addFieldToTab

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 503 Views
  • nicanor
    Avatar
    Community Member
    15 Posts

    SortOrder increment before addFieldToTab Link to this post

    I can get SortOrder Value in Admin Backend with SortOrder in DataObjectManager array like this:

    $f->addFieldToTab("Root.Content.Mysite", new DataObjectManager(

             $this,

             'Persons',

             'PersonObject',

             array('Thumb' => 'Thumb','Name' => 'Name','Url' => 'Url','Category'=>'Category','Languages'=>'Languages','Countries' => 'Countries','SortOrder' => 'SortOrder'),

                   'getCMSFields_forPopup'

             ));

    I have no idea how to increment the value in this Page Model. How can i access SortOrder before addFieldToTab?

  • nicanor
    Avatar
    Community Member
    15 Posts

    Re: SortOrder increment before addFieldToTab Link to this post

    I added a function to the corresponding Data Object.

    Like described in datamodel http://doc.silverstripe.org/sapphire/en/topics/datamodel i have overwritten the getSortOder funct.

    function getSortOrder() {

    // SortOrder is not working
    //return $this->SortOrder;

    return->Name;
    }

    But i can not access the field SortOrder. With Name, like in the code it works.

    i thought it could be perhaps

    $this->Sort
    $this->Order

    but don't work.

    I have not defined SortOrder, this field is from Dataobjectmodel auto generated per _config.php

    SortableDataObject::add_sortable_class('PersonObject');

    In Admin Backend first element shows nothing because SortOrder=0. That's why i like to override getSortOrder with - something like -

    return ($this-SortOrder+1);

    503 Views
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.