Jump to:

5453 Posts in 1674 Topics by 1198 members

Customising the CMS

SilverStripe Forums » Customising the CMS » renameField has no effect

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 3109 Views
  • david_nash
    Avatar
    Community Member
    55 Posts

    renameField has no effect Link to this post

    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?

  • david_nash
    Avatar
    Community Member
    55 Posts

    Re: renameField has no effect Link to this post

    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!

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: renameField has no effect Link to this post

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

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: renameField has no effect Link to this post

    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');

  • Ironcheese
    Avatar
    Community Member
    33 Posts

    Re: renameField has no effect Link to this post

    Thanks timwjohn! You saved me alot of hassle

    Your Code works perfect.

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: renameField has no effect Link to this post

    Glad to help!

  • ajshort
    Avatar
    Community Member
    244 Posts

    Re: renameField has no effect Link to this post

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

    Save yourself a bit of typing

  • timwjohn
    Avatar
    Community Member
    98 Posts

    Re: renameField has no effect Link to this post

    Nice!

    3109 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.