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.

Customising the CMS

renameField has no effect


Go to End
Reply

11 Posts   3476 Views

Avatar
david_nash

8 May 2009 at 1:14pm Community Member, 55 Posts

As far as I can tell I'm using it correctly, but it doesn't do anything.

eg:

class CoursePage extends Page {
...   

   function getCMSFields() {
      $fields = parent::getCMSFields();
      $fields->renameField('Content', 'Other');
      return $fields;
   }

}

My 'Content' tab should now have the label 'Other', correct?

Avatar
david_nash

8 May 2009 at 4:03pm Community Member, 55 Posts

Okay maybe it is working, but I still don't understand how to use it.

The code posted above will change the label above the TinyMCE editor.

What I want to do is rename a tab.

Is it correct that I should just need to call $fields->renameField('Root.Content.Main', 'Root.Content.OtherName'); ?

Is it even possible to rename tabs?

Have I got the names wrong? Please help! :-)

Avatar
timwjohn

4 April 2010 at 2:37am Community Member, 98 Posts

I guess that it's a no for being able to rename tabs then?

Avatar
timwjohn

4 April 2010 at 2:57am Community Member, 98 Posts

Ok, I figured it out. In ModelAdmin the code to rename 'Main' tab is:

$main = $fields->fieldByName('Root')->fieldByName('Main');
      $main->setTitle('Other');

In Pages it would probably be something like:

$main = $fields->fieldByName('Root')->fieldByName('Content')->fieldByName('Main');
      $main->setTitle('Other');

Avatar
Ironcheese

10 July 2010 at 11:22pm Community Member, 33 Posts

Thanks timwjohn! You saved me alot of hassle :D

Your Code works perfect.

Avatar
timwjohn

12 July 2010 at 10:12pm Community Member, 98 Posts

Glad to help!

Avatar
ajshort

12 July 2010 at 11:35pm Community Member, 244 Posts

$fields->fieldByName('Root.Content.Main')->setTitle('Other');

Save yourself a bit of typing :)

Avatar
timwjohn

12 July 2010 at 11:51pm Community Member, 98 Posts

Nice!

Go to Top