Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Bad class to singleton error when extending PageComment class

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: 2426 Views
  • ivanhoe
    Avatar
    Community Member
    2 Posts

    Bad class to singleton error when extending PageComment class Link to this post

    I'm trying to add a couple of extra DB fields to page comments, but I've got totally stuck with the error from the title. Code in questions is:

    class OurPageComment extends PageComment {
       static $db = array(
          "Company" => "Varchar(100)",
          "Email" => "Varchar(255)",
          "Homepage" => "Varchar(255)",
       );
    }

    As you can see I've just tried extending PageComment the same way it's done with other classes in tutorials/docs, but it obviously can't be done that way.

    Error trace (when I go to /db/build/..):

    * Bad class to singleton() - OurPageComment
    Line 263 of Core.php
    * singleton(OurPageComment)
    Line 161 of DatabaseAdmin.php
    * DatabaseAdmin->doBuild()
    Line 81 of DatabaseAdmin.php
    * DatabaseAdmin->build(HTTPRequest)
    Line 162 of Controller.php
    * Controller->handleAction(HTTPRequest)
    Line 107 of RequestHandler.php
    * RequestHandler->handleRequest(HTTPRequest)
    Line 122 of Controller.php
    * Controller->handleRequest(HTTPRequest)
    Line 257 of Director.php
    * Director::handleRequest(HTTPRequest,Session)
    Line 106 of Director.php
    * Director::direct(db/build)
    Line 111 of main.php

  • ivanhoe
    Avatar
    Community Member
    2 Posts

    Re: Bad class to singleton error when extending PageComment class Link to this post

    Ok, I managed to solve the problem, the class that extends PageComment has to be in a separate file. I had it defined in the same file where my page class is defined and SS couldn't find it there obviously.

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