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.

General Questions

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

ModelAdmin - Adding new tabs in right panel


Reply

4 Posts   2860 Views

Avatar
Sec

16 June 2009 at 8:26pm Community Member, 13 Posts

Trying to figure out ModelAdmin. Documentation is poor, so I hope someone else can share their experience with the ModelAdmin module.

I have set up a standard Aritcle - Category relation (basically the same as in the docs). When creating a new article, I get the article fields in a Main-tab in the right column panel. How do I add tabs to the new item action? E.g. I want a Image tab where I can set up various image uploads. Anyone have any experience with this?

I would also appreciate tips to where I can find docs on how to expand the module.

Thanks!

Avatar
Willr

17 June 2009 at 8:06pm Forum Moderator, 5511 Posts

It automatically scaffolds the form fields. if you want to display it tabbed rather then the default I think you need to add a getCMSFields() function to your dataobject article and build up the interface the same way you do with CMSFields for pages - http://doc.silverstripe.com/doku.php?id=getcmsfields you would also need to create the tabs as well (since none exist) - http://doc.silverstripe.com/doku.php?id=tabset

Avatar
joelg

9 February 2010 at 4:10am Community Member, 129 Posts

Hi Willr

I was just looking for this and as usual everything is über simple with SilverStripe. This code makes a new tab - without creating any new tabset:

function getCMSFields() {
      
      $fields = parent::getCMSFields();
       $fields->addFieldToTab('Root.Main', new ImageField("Picture", "Upload avatar."));
      return $fields;
   }

Avatar
BenWu

18 May 2012 at 11:51pm Community Member, 90 Posts

When i want to put the image field to another tab, i just do

$fields->addFieldToTab('Root.Images', new ImageField("Picture", "Upload avatar."));

and SS will remove the picture field from the Main and put it in the Images tab