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.

Archive

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

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

Tutorial 2 - Date / Author Not Saving


Reply

4 Posts   1194 Views

Avatar
Craig

20 September 2008 at 7:23am Community Member, 6 Posts

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

Avatar
Craig

20 September 2008 at 7:46am Community Member, 6 Posts

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?

Avatar
Hamish

20 September 2008 at 9:24am Community Member, 712 Posts

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.

Avatar
Craig

20 September 2008 at 9:28am Community Member, 6 Posts

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.