Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » TextField not displaying in CMS

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 883 Views
  • Sparrowhawk
    Avatar
    Community Member
    33 Posts

    TextField not displaying in CMS Link to this post

    Hi,

    I wonder if somebody could help me out. I have a new Page Type, SupporterPage. It's basically the same as a normal Page with the addition of a website URL field:

    <?php
    class SupporterPage extends Page {
    static $db = array('SupporterWebsite' => 'Varchar(255)');
    static $has_one = array();

    static $icon = 'themes/VansBP/images/treeicons/supporter';

    public function getCMSFields() {
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Main', new TextField('SupporterWebsite'), 'Website');

    return $fields;
    }

    }
    class SupporterPage_Controller extends Page_Controller {

    }

    Problem is, the SupporterWebsite field does not appear on the CMS page. I have rebuilt the database (/dev/build/?flush=1) and the tables have been created, with the correct field added. It's just the CMS field that won't show.

    If I change the tab to something like Root.Content.Website, then a new tab gets created, but the field still does not show.

    Anyone have any ideas - have I made a newb error?! ;)

  • socks
    Avatar
    Community Member
    190 Posts

    Re: TextField not displaying in CMS Link to this post

    new TextField('SupporterWebsite'), 'Website');

    You're telling it to put a field above the Website field, which doesn't exist.

    This will rename the field to "Supporter Website URL" and put it above the Content field. If you remove the Content reference, it will appear at the bottom.

    new TextField('SupporterWebsite', 'Supporter Website URL'), 'Content');

  • Sparrowhawk
    Avatar
    Community Member
    33 Posts

    Re: TextField not displaying in CMS Link to this post

    Hi Socks,

    Thanks for the reply. Now that you point it out, it's quite obvious and I really should have picked up on my misplaced bracket.

    Thanks for your help, much appreciated.

    883 Views
Page: 1
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.