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   3514 Views

Avatar
david_nash

Community Member, 55 Posts

8 May 2009 at 1:14pm

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

Community Member, 55 Posts

8 May 2009 at 4:03pm

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

Community Member, 98 Posts

4 April 2010 at 2:37am

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

Avatar
timwjohn

Community Member, 98 Posts

4 April 2010 at 2:57am

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

Community Member, 33 Posts

10 July 2010 at 11:22pm

Thanks timwjohn! You saved me alot of hassle :D

Your Code works perfect.

Avatar
timwjohn

Community Member, 98 Posts

12 July 2010 at 10:12pm

Glad to help!

Avatar
ajshort

Community Member, 244 Posts

12 July 2010 at 11:35pm

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

Save yourself a bit of typing :)

Avatar
timwjohn

Community Member, 98 Posts

12 July 2010 at 11:51pm

Nice!

Go to Top