10

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

Elrond_EGLDer
  • 47,430
  • 25
  • 189
  • 180
spierala
  • 1,470
  • 1
  • 16
  • 37

2 Answers2

18

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.

Shane Garelja
  • 1,418
  • 10
  • 10
2

This method worked for me:

public function updateSettingsFields(FieldList $fields) {
  $fields->addFieldToTab("Root.MyNewSettingsSubTab", new TextField('Intro'));
  return $fields;
}
BaronGrivet
  • 4,043
  • 5
  • 32
  • 49
  • 1
    Just worth noting you'd use this method if doing via a ```DataExtension```, however if you're doing it via a class that extends from ```Page``` the first answer is what you'd use. – Chris Turner Jan 01 '16 at 20:29