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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

DB being overwritten on build


Go to End


2 Posts   1209 Views

Avatar
sonicparke

74 Posts

11 July 2008 at 3:12pm

I'm trying to add a custom tab. I've added the code below to add the tab to Page.php and when I rebuild the db it drops all my info and gives me a default build.

<?php

class Page extends SiteTree {
	static $db = array(
		"AnnouncementContent" => "Text",
   );
   
   function getCMSFields() {
   $fields = parent::getCMSFields();
 
	$fields->addFieldToTab('Root.Content.Main', new TextField('AnnouncementContent'), 'Content');
    	
   return $fields;
	}
	static $has_one = array(
   );
}

class Page_Controller extends ContentController {
	function init() {
		parent::init();
		
		Requirements::themedCSS("layout");
		Requirements::themedCSS("typography");
		Requirements::themedCSS("form");
	}
}

?>

At this point wouldn't the added code just add the field in the CMS? Why is it dropping my db?

Avatar
sonicparke

74 Posts

11 July 2008 at 5:25pm

OK. I figured it out and it's really stupid. Last week I switched from a Dell to a MacBook Pro. I had accidentally used ?flush-1 rather than ?flush=1. it took me a while to notice it. Oops.