Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

silverstripe 3 addFieldToTab "Settings"

I want to add a Field to the existing Tab "Settings" of Edit Page View (marked in the screenshot).

I tried this:

$fields->addFieldToTab('Root.Settings', new TextField('Intro'));

But it just adds a new tab next to the secondary Tab "Main Content" containing the additional Field.

Silverstripe Edid Page View

like image 233
spierala Avatar asked Aug 15 '12 09:08

spierala


2 Answers

For SilverStripe 3.0 you need to override the getSettingsFields() function in your Model e.g.

function getSettingsFields() {
    $fields = parent::getSettingsFields();
    $fields->addFieldToTab("Root.Settings", new TextField('Intro'));
    return $fields;
}

In SilverStripe 2.x this is done in the getCMSFields() function.

like image 83
Shane Garelja Avatar answered Nov 02 '22 09:11

Shane Garelja


This method worked for me:

public function updateSettingsFields(FieldList $fields) {
  $fields->addFieldToTab("Root.MyNewSettingsSubTab", new TextField('Intro'));
  return $fields;
}
like image 29
BaronGrivet Avatar answered Nov 02 '22 09:11

BaronGrivet