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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DataObjectManager with optional files


Go to End


2 Posts   824 Views

Avatar
nafetsch

Community Member, 15 Posts

2 August 2010 at 11:17pm

Hey Guys,

Need a little help.

I want to use the DataObjectManager because I have a lot of text fields and NOT EVERTIME A FILE. Or is it possible to use the FileDataObjectManager with optional Fileupload?

Here is my code:

<?php

class DataLinks extends DataObject
{
static $db = array (
'Author' => 'Text',
'Quote' => 'HTMLText'
);

static $has_one = array (
'DataLinks' => 'Links',
'Attachment' => 'File',

);

public function getCMSFields_forPopup()
{
return new FieldSet(

new TextField('Author'),
new TextareaField('Quote'),
new FileIFrameField('Attachment')

);
}
}

and

class Links extends Page {

static $has_many = array
(
'DataLinkss' => 'DataLinks',

);

function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Testimonials", new DataObjectManager(
$this,
'DataLinkss',
'DataLinks',
'Attachment',
array('Date' => 'Date','Author'=>'Author','Quote' => 'Quote'),
'getCMSFields_forPopup'
));
return $fields;
}
}

class Links_Controller extends Page_Controller {
}

Here is the error:
[User Error] Couldn't run query: SELECT "DataLinks"."ClassName", "DataLinks"."Created", "DataLinks"."LastEdited", "DataLinks"."Author", "DataLinks"."Quote", "DataLinks"."DataLinksID", "DataLinks"."AttachmentID", "DataLinks"."ID", CASE WHEN "DataLinks"."ClassName" IS NOT NULL THEN "DataLinks"."ClassName" ELSE 'DataLinks' END AS "RecordClassName" FROM "DataLinks" WHERE ((getCMSFields_forPopup) AND ("DataLinksID" = '100')) ORDER BY Created DESC LIMIT 10 OFFSET 0 Unknown column 'getCMSFields_forPopup' in 'where clause'

Plz help...

Avatar
nafetsch

Community Member, 15 Posts

2 August 2010 at 11:23pm

sorry! perhaps i clicked the post button twice. plz delete one of the posts with no anthers.