Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » DB being overwritten on build

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: 881 Views
  • sonicparke
    Avatar
    74 Posts

    DB being overwritten on build Link to this post

    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?

  • sonicparke
    Avatar
    74 Posts

    Re: DB being overwritten on build Link to this post

    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.

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