Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Tutorial 2: New fields not showing up on CMS

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1595 Views
  • DonL
    Avatar
    Community Member
    9 Posts

    Tutorial 2: New fields not showing up on CMS Link to this post

    I've added the $Author and $Date code to ArticlePage.php and flushed both the DB and the CMS, but the fields still aren't showing up in the CMS. Any ideas what to look for?

    <?php
    /**
    * Defines the ArticlePage page type
    */
    class ArticlePage extends Page {
    static $db = array(
       'Date' => 'Date',
       'Author' => 'Text'
    );
    static $has_one = array(
    );

    static $allowed_children = array('ArticlePage');

    }

    class ArticlePage_Controller extends Page_Controller {

    }

    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
    $fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
       
    return $fields;
    }

    ?>

    The DB has been updated - the pages are there when I re-flush.

    Building Database

    Creating database tables
    # Newsletter
    # Newsletter_SentRecipient
    # Newsletter_Recipient
    # NewsletterType
    # PageComment
    # Email_BounceRecord
    # Email_BlackList
    # PageView
    # SiteTree
    # QueuedEmail
    # File
    # EditableCheckboxOption
    # EditableDropdownOption
    # EditableFormField
    # EditableRadioOption
    # SubmittedForm
    # SubmittedFormField
    # Group
    # Member
    # Member_UnsubscribeRecord
    # Permission
    # Widget
    # WidgetArea
    # GhostPage
    # Page
    # UserDefinedForm
    # ErrorPage
    # RedirectorPage
    # VirtualPage
    # ArticleHolder
    # ArticlePage
    # HomePage
    # SubscribeForm
    # Image
    # Folder
    # Image_Cached
    # EditableCheckbox
    # EditableCheckboxGroupField
    # EditableDateField
    # EditableDropdown
    # EditableEmailField
    # EditableFileField
    # EditableFormHeading
    # EditableMemberListField
    # EditableRadioField
    # EditableTextField
    # SubmittedFileField
    # Group_Unsecure

    Creating database records
    # Newsletter
    # Newsletter_SentRecipient
    # Newsletter_Recipient
    # NewsletterType
    # PageComment
    # Email_BounceRecord
    # Email_BlackList
    # PageView
    # SiteTree
    # QueuedEmail
    # File
    # EditableCheckboxOption
    # EditableDropdownOption
    # EditableFormField
    # EditableRadioOption
    # SubmittedForm
    # SubmittedFormField
    # Group
    # Member
    # Member_UnsubscribeRecord
    # Permission
    # Widget
    # WidgetArea
    # GhostPage
    # Page
    # UserDefinedForm
    # ErrorPage
    # RedirectorPage
    # VirtualPage
    # ArticleHolder
    # ArticlePage
    # HomePage
    # SubscribeForm
    # Image
    # Folder
    # Image_Cached
    # EditableCheckbox
    # EditableCheckboxGroupField
    # EditableDateField
    # EditableDropdown
    # EditableEmailField
    # EditableFileField
    # EditableFormHeading
    # EditableMemberListField
    # EditableRadioField
    # EditableTextField
    # SubmittedFileField
    # Group_Unsecure

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: Tutorial 2: New fields not showing up on CMS Link to this post

    Easy, your getCMSFields() function needs to go inside the ArticlePage class. You've currently got it outside of it.

  • DonL
    Avatar
    Community Member
    9 Posts

    Re: Tutorial 2: New fields not showing up on CMS Link to this post

    Oops! Heh.

  • DonL
    Avatar
    Community Member
    9 Posts

    Re: Tutorial 2: New fields not showing up on CMS Link to this post

    Well, I've moved getCMSFields into the controller, flushed everything... and still don't see the fields in the CMS.

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: Tutorial 2: New fields not showing up on CMS Link to this post

    It should be in the ArticlePage class, not ArticlePage_Controller.

    1595 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.