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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

ModelAsController::getNestedController() returned bad object type

Go to End

4 Posts   3922 Views


Community Member, 9 Posts

20 August 2010 at 8:05am

I'm not sure this is a DataObjectManager problem, but I have been struggling with this for a week now and can't find a solution.

I am building a video gallery for a site i'm working on and I keep getting this error when I view the live page on the site. The strange thing is it was working at first and now, nothing.

[User Warning] ModelAsController::getNestedController() returned bad object type 'VideoPage'
GET /gc/video/

Line 70 in C:\xampp\htdocs\gc\sapphire\core\control\ModelAsController.php


61 }
63 try {
64 $result = $this->getNestedController();
66 if($result instanceof RequestHandler) {
67 $result = $result->handleRequest($this->request);
68 } else if(!($result instanceof SS_HTTPResponse)) {
69 user_error("ModelAsController::getNestedController() returned bad object type '" .
70 get_class($result)."'", E_USER_WARNING);
71 }
72 } catch(SS_HTTPResponse_Exception $responseException) {
73 $result = $responseException->getResponse();
74 }
76 $this->popCurrent();

ModelAsController::getNestedController() returned bad object type 'VideoPage'
Line 70 of ModelAsController.php
Line 283 of Director.php
Line 127 of Director.php
Line 127 of main.php

Here is my code.


class Video extends DataObject {

static $db = array (
'Title' => 'Text',
'Date' => 'Date',
'AddedBy' => 'Text',
'Category' => 'Text',
'Description' => 'Text',
'VideoShortCode' => 'HTMLText'

static $has_one = array (
'VideoPage' => 'VideoPage'

public function getCMSFields_forPopup()
return new FieldSet(
new TextField('Title'),
new DatePickerField('Date'),
new TextField('AddedBy'),
new TextField('Category'),
new TextareaField('Description'),
new TextField('VideoShortCode')


class VideoPage extends Page {

static $icon = "video_gallery/images/vidicon";

static $db = array (
'VideoWidth' => 'Int',
'VideoHeight' => 'Int'
static $has_many = array (
'Videos' => 'Video'

static $defaults = array (
'VideoWidth' => '320',
'VideoHeight' => '210'

public function getCMSFields()
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Videos", new DataObjectManager(
array('Title' => 'Title','Date' => 'Date','AddedBy'=>'AddedBy','Category'=>'Category','Description' => 'Description','VideoShortCode' => 'VideoShortCode'),
$f->addFieldToTab("Root.Content.Configuration", new HeaderField($title = ('Defaults'), $headingLevel = "3"));
$f->addFieldToTab('Root.Content.Configuration', new NumericField('VideoWidth','Video Width'));
$f->addFieldToTab('Root.Content.Configuration', new NumericField('VideoHeight','Video Height'));
return $f;

And here is the template I'm using.

<% if Videos %>
<% control Videos %>
<div id="video-list">
<table width="600" border="0" cellpadding="0" cellspacing="0">
<td colspan="2"><div id="video-list_title">$Title</div></td>
<td><div id="video-list_subtitle">Added By: $AddedBy on $Date</div></td>
<td rowspan="2"><div id="video-list_window">$VideoShortCode</td>
<td valign="top"><div id="video-list_description">$Description</div></td>
<% end_control %>
<% end_if %>

I have tried everything I can think of and I still get the error. Any help would be appreciated.


Community Member, 4 Posts

30 October 2010 at 4:24am

Hi Tesla,

I'm guessing this response is a couple of months too late(!) for you but for others searching this error on the forum I thought I would post the solution.

Your VideoPage.php file must extend the Page_Controller class as well. So your file should look like:

class VideoPage extends Page {



class VideoPage_Controller extends Page_Controller {
	public static $allowed_actions = array (

	public function init() {

I inadvertently created the same problem when I removed my file and Page class and forgot to rename the controller class.


Community Member, 49 Posts

4 February 2011 at 12:47pm

Thanks hornergraphic, thats just helped me out heaps.. i was thinking an uninstall was on the cards..


Community Member, 3 Posts

31 March 2013 at 10:33pm

As an FYI, this can also occur if you haven't specified a controller, or you've accidentally renamed the controller to something different.