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.

Form Questions /

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

loadUploaded creates record with wrong ClassName?

Go to End

3 Posts   1444 Views


Community Member, 165 Posts

14 May 2010 at 9:33am

I'm trying to create a form, on the front end, where users can upload a logo.

I am using a SimpleImageField

$fields = new FieldSet(
new SimpleImageField (
$name = "LogoImageID",
$title = "Upload a logo (2Mb maximum filesize)"
$form = new Form($this, 'ShowProfileForm', $fields, $actions, );
return $form;

function btnSaveInfo($data, $form) {

$file = new File();

And that WORKS, except that the Image is saved with a ClassName of "File" rather than "Image". So it doesn't display on the template or do anything useful.

I can't find any documentation on how to set the ClassName.

When I try updating the ClassName with a DataObject::get_by_id, I get a message about backlinktracking not being supported. And anyway, it's a total kludge of a solution.

At the moment, I can get it to work by simply updating the record with a DB:query (even more of a kludge), but there's got to be a better solution.

I can't be the only guy that's noticed this problem, so I am sure I'm doing something wrong.

Any suggestions?


Community Member, 323 Posts

15 May 2010 at 9:09am


Can’t you simply use $file = new Image(); ?

Hope it helps,


Community Member, 165 Posts

16 May 2010 at 5:48pm

Edited: 16/05/2010 5:53pm


Yes, that's definitely worth a try. Thanks for the suggestion! :)


Yup. It works, thanks for that. I guess I should read and adapt the documentation rather than take it literally.