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, biapar, Willr, Ingo, swaiba, simon_w

Error when trying out the FileDataObjectManager


Reply


3 Posts   1372 Views

Avatar
adesweb

Community Member, 39 Posts

2 July 2009 at 11:08pm

Hi,

I am following the tutorial for this module in the documentation. The DataObjectManager (Testimonial stuff) works fine. However, the next bit for the ResourcePage comes up with this error when adding a new page in the CMS:

ERROR [User Error]: getCMSFields returned null on a 'Page' object - it should return a FieldSet object. Perhaps you forgot to put a return statement at the end of your method?
IN POST /silverstripe/admin/getitem?ID=6&ajax=1
Line 392 in /home/adrianw/PROJECTS/sandbox/silverstripe/cms/code/CMSMain.php

Source
======
383:

384:    public function getEditForm($id) {

385:       $record = $this->getRecord($id);

386:

387:       if($record) {

388:          if($record->IsDeletedFromStage) $record->Status = _t('CMSMain.REMOVEDFD',"Removed from the draft
site");

389:

390:          $fields = $record->getCMSFields($this);

391:          if ($fields == null) {

* 392:             user_error("getCMSFields returned null on a 'Page' object - it should return a FieldSet object.
Perhaps you forgot to put a return statement at the end of your method?", E_USER_ERROR);

393:          }

394:          $fields->push($idField = new HiddenField("ID"));

395:          $fields->push($liveURLField = new HiddenField("LiveURLSegment"));

396:          $fields->push($stageURLField = new HiddenField("StageURLSegment"));

397:

398:          /*if( substr($record->ID, 0, 3 ) == 'new' )*/

<ul>user_error(getCMSFields returned null on a 'Page' object - it should return a FieldSet object. Perhaps you forgot to put a return statement at the end of your method?,256)
line 392 of CMSMain.php

CMSMain->getEditForm(6)
line 925 of LeftAndMain.php

LeftAndMain->EditForm()
line 380 of LeftAndMain.php

LeftAndMain->getitem(HTTPRequest)
line 162 of Controller.php

Controller->handleAction(HTTPRequest)
line 129 of RequestHandler.php

RequestHandler->handleRequest(HTTPRequest)
line 122 of Controller.php

Controller->handleRequest(HTTPRequest)
line 277 of Director.php

Director::handleRequest(HTTPRequest,Session)
line 121 of Director.php

Director::direct(/admin/getitem)
line 118 of main.php

</ul>

Can you help? I am using the latest version of Silverstripe (2.3.2)

Adrian

Avatar
adesweb

Community Member, 39 Posts

2 July 2009 at 11:26pm

Apologies, have realised the error. The two lines are missing from the tutorial code:

$f->addFieldToTab("Root.Content.Resources", $manager);
return $f;

Cheers,

Adrian

Avatar
UncleCheese

Forum Moderator, 4096 Posts

3 July 2009 at 1:38am

Thanks for pointing that out. I'll make the update.