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

trying to adapt ressource example to modeladmin


Go to End
Reply


11 Posts   1449 Views

Avatar
servalman

Community Member, 211 Posts

17 June 2011 at 5:51am

Edited: 17/06/2011 6:02am

Hello Uncle cheese

Sorry for the previous post

I got it almost to work.

When I create a work :
I got to tabs
Main where I can putthe 'name' and define categorie attached to the work
Files where I can upload files

When I add (save) the work I get to see a third tab wich seems normal according to :

new MultipleFileUploadField('UploadedFiles','Files'));

But I'm left with a problem
There is no thumbnail when I save the uploaded file
also There is nothing in the UploadedFiles tab.

<?php
class Work extends DataObject {

static $db = array(
'Name' => 'Varchar'
);

static $has_one = array(
'Category' => 'Category'
);

static $has_many = array (
'UploadedFiles' => 'WorkFile'
);

static $searchable_fields = array(
'Name'
);

public function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Files", new MultipleFileUploadField('UploadedFiles','Files');
return $fields;
}
}

I'm gonna try to find out by myself but if you have any idea

Thanks

Avatar
UncleCheese

Forum Moderator, 4094 Posts

21 June 2011 at 4:55am

You need to populate the dropdown with options..

$map = array();
if($result = DataObject::get("Category")) {
$map = $result->toDropdownMap();
}

...

new DropdownField('CategoryID','Category',$map);

Avatar
servalman

Community Member, 211 Posts

21 June 2011 at 5:23am

Hello

I'm getting confused ;)

Here you're talking about the categori dropdown right ?

It seems to be working now after I set up a tab to upload the files.

My problem now is that after I save the uploaded files the images seems to desapear and there is nothing under the tab uploaded file.

(in the ressource example you get to see what has been uploaded)

Maybe I'm doing something wrong or not understanding how it works

Thanks

Go to Top