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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

SortOrder increment before addFieldToTab


Reply


2 Posts   524 Views

Avatar
nicanor

Community Member, 15 Posts

26 October 2011 at 12:47am

Edited: 26/10/2011 12:52am

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?

Avatar
nicanor

Community Member, 15 Posts

27 October 2011 at 2:03am

I added a function to the corresponding Data Object.

Like described in datamodel [url]http://doc.silverstripe.org/sapphire/en/topics/datamodel[/url] 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);