Sigal Zahavi
Sigal Zahavi

Reputation: 1073

Silverstipe tutorial - addFieldToTab does not work

I am following silverstripe tutorial number 2: Extending a basic site http://doc.silverstripe.org/framework/en/tutorials/2-extending-a-basic-site

I have downloaded ss3.0.3 and using Windows 7 WAMP 2.1

I have created the ArticlePage and ArticleHolderPage but when I go and create a page of type ArticleHolder there are no date and author fields in the content tab.

My code for the ArticlPage:

class ArticlePage extends Page
{
    static $db = array(
         'Date'=>'Date',
         'Author'=>'Text'
      );

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

      $dateField = new DateField('Date');
      $dateField = setConfig('showcalendar', true);
      $fields->addFieldToTab('Root.Main', $dateField, 'Content');
      $fields->addFieldToTab('Root.Main', new TextField('Author'), 'Content');

      return $fields;
   }
}

Am I doing something wrong?

Thank you

Upvotes: 0

Views: 437

Answers (1)

schellmax
schellmax

Reputation: 6094

oh, i was too quick with my comment above, just found an error in your code:

$dateField = setConfig('showcalendar', true);

should read

$dateField->setConfig('showcalendar', true);

Upvotes: 2

Related Questions