Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » trying to adapt ressource example to modeladmin

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 1207 Views
  • servalman
    Avatar
    Community Member
    211 Posts

    Re: trying to adapt ressource example to modeladmin Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: trying to adapt ressource example to modeladmin Link to this post

    You need to populate the dropdown with options..

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

    ...

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

  • servalman
    Avatar
    Community Member
    211 Posts

    Re: trying to adapt ressource example to modeladmin Link to this post

    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

    1207 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.