Solutions to errors

This pages provides an overview of some common SilverStripe errors that have cryptic error messages. Hopefully these examples will help you out.

[User Warning] Already directed to http://localhost/; now trying to direct to /another-page

Add response->removeHeader('Location'); to your controller to remove the previous redirect.

$controller = Controller::curr();
return $controller->redirect(Director::BaseURL() . 'another-page');

[User Warning] ModelAsController::getNestedController() returned bad object type 'Examples'

GET /examples/?flush=1
Line 70 in \sapphire\core\control\ModelAsController.php


This error occurs if no controller is defined for a class based on Page / SiteTree. Define controller at bottom of your Example class as:

class Examples extends Page {
// Your Examples class

class Examples_Controller extends Page_Controller {


Relation DataObjectManagers (DOM module)

Issues with HasOneDataObjectManager HasManyDataObjectManager ManyManyDataObjectManager

Error: [User Warning] Can't figure out the data class of

GET /admin/security/EditForm/field/Members/item/43/edit

Line 28 in \dataobject_manager\code\HasManyDataObjectManager.php

The error occurs if you are using $this rather than $this->owner when extending DataObjectDecorator / Extension.

       $manager = new ManyManyDataObjectManager($this->owner, "Expertise", "ExpertsHolder", array('Title' => 'Title'), "getCMSFields_forPopup", '', 'Title ASC');
        $manager->setPluralTitle('Expertise areas');
        $fields->addFieldToTab("Root.Expertise", $manager);