7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » SortOrder increment before addFieldToTab
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 286 Views |
-
SortOrder increment before addFieldToTab

26 October 2011 at 12:47am Last edited: 26 October 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?
-
Re: SortOrder increment before addFieldToTab

27 October 2011 at 2:03am
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->Orderbut 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);
| 286 Views | ||
|
Page:
1
|
Go to Top |

