Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Custom fields not showing 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: 1362 Views
  • aquafina
    Avatar
    Community Member
    1 Post

    Custom fields not showing on CMS Link to this post

    Hello,

    I was following http://doc.silverstripe.com/doku.php?id=tutorial:2-extending-a-basic-site. I got the database built fine and I can create new page of type ArticleHolder and ArticlePage. However, when I'm on Article Page, I don't see new fields on CMS. I did flush on both http://mysite/db/build?flush=1 and http://mysite/admin/?flush=1.

    I put the code to override getCMSFields() under mysite/code/ArticlePage.php under ArticlePage_Controller class. It seems like the function is not being called (I checked using syslog() on the function and I don't see anything)

    Any pointers / help is appreciated.

  • Willr
    Avatar
    Forum Moderator
    5489 Posts

    Re: Custom fields not showing on CMS Link to this post

    It should be in the ArticlePage class and NOT the controller. The controller class usually only has methods which are used in the templates. Things like getCMSFields() should be in the top class.

  • kudesign
    Avatar
    Community Member
    64 Posts

    Re: Custom fields not showing on CMS Link to this post

    I still have no luck adding the method to the ArticlePage class, this is my code in code/ArticlePage.php

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

    class ArticlePage_Controller extends Page_Controller {

    }

    ?>

    After db/build?flush=1 and multiple refreshes, it still does not show the Date and Author field when I tried to add a new ArticlePage in CMS. I'm on v2.2.3 What have I done wrong? Help!

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