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
Source
61 }
62
63 try {
64 $result = $this->getNestedController();
65
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 }
75
76 $this->popCurrent();
Trace
ModelAsController::getNestedController() returned bad object type 'VideoPage'
Line 70 of ModelAsController.php
ModelAsController->handleRequest(SS_HTTPRequest)
Line 283 of Director.php
Director::handleRequest(SS_HTTPRequest,Session)
Line 127 of Director.php
Director::direct(/video/)
Line 127 of main.php
Here is my code.
Video.php
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')
);
}
}
VideoPage.php
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(
$this,
'Videos',
'Video',
array('Title' => 'Title','Date' => 'Date','AddedBy'=>'AddedBy','Category'=>'Category','Description' => 'Description','VideoShortCode' => 'VideoShortCode'),
'getCMSFields_forPopup'
));
$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">
<tr>
<td colspan="2"><div id="video-list_title">$Title</div></td>
</tr>
<tr>
<td><div id="video-list_subtitle">Added By: $AddedBy on $Date</div></td>
<td rowspan="2"><div id="video-list_window">$VideoShortCode</td>
</tr>
<tr>
<td valign="top"><div id="video-list_description">$Description</div></td>
</tr>
</table>
</div>
<% end_control %>
<% end_if %>
I have tried everything I can think of and I still get the error. Any help would be appreciated.