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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

TextField not displaying in CMS


Go to End


3 Posts   1199 Views

Avatar
Sparrowhawk

Community Member, 33 Posts

17 October 2009 at 3:52am

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?! ;)

Avatar
socks

Community Member, 191 Posts

17 October 2009 at 6:22am

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

Avatar
Sparrowhawk

Community Member, 33 Posts

19 October 2009 at 10:12pm

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.