Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Tutorial 2 - Date / Author Not Saving

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: 1170 Views
  • Craig
    Avatar
    Community Member
    6 Posts

    Tutorial 2 - Date / Author Not Saving Link to this post

    While working through tutorial 2 I was able to add the Date and Author the the main tab in ArticlePage and get it to show up in the tab itself. But when I create the news story and save or publish, the data for the added fields Date and Author did not save properly though the rest of the content did.

    My ArticalePage.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 {

    }
    ?>

    I'm doing this in my site and this file lives in mysite/code directory.

    Is there something small / obvious that I'm missing? The best I can tell my code is basically verbatim from the tutorial.

    Cheers,

    Craig

  • Craig
    Avatar
    Community Member
    6 Posts

    Re: Tutorial 2 - Date / Author Not Saving Link to this post

    OK, so what seemed like the 50th time I did /db/build and it finally created the tables.

    So my question now is - is there a difference between /db/build/?flush=1 and simply /db/build?

    If both are valid, when is each appropriate?

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Tutorial 2 - Date / Author Not Saving Link to this post

    I always use db/build?flush=1. Flushing does a bunch of extra stuff, and generally if you've changed your classes you need to flush.

  • Craig
    Avatar
    Community Member
    6 Posts

    Re: Tutorial 2 - Date / Author Not Saving Link to this post

    That's interesting as /db/build/?flush=1 was how I was doing it, but it wasn't until I only did /db/build were the new tables added to the database. I'll watch more closely the next time I do this. Only my 2nd day working with SS, but to this point like what I see over all.

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