Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Uploadify: features not working with FileDOM, working with DOM

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 932 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    Uploadify: features not working with FileDOM, working with DOM Link to this post

    Been using uploadify with DOM and it is great! However, some of the more fine grained features are not working for me when I'm using uploadify with a FileDOM. I cannot get the allowFolderSelection, setuploadFolder, or setFileTypes settings to work with a fileDOM. Also the button text doesn't change with the FileDOM.

    DOM example field definition:

    $imageUploadField = new ImageUploadField(
    'Photo',
    'Upload a Photo',
    array(
    'buttonText' => 'Upload an Image'
    )
    );

    $imageUploadField->setuploadFolder('Images/UsedEquipment');
    $imageUploadField->allowFolderSelection = false;


    DOM definition:

    {
    $fields = parent::getCMSFields();
    $datamanager = new DataObjectManager(
    $this, // Controller
    'UsedEquips', // Source name
    'UsedEquip', // Source class
    array(
    'Name' => 'Name',
    'Overview' => 'Overview',
    'Description' => 'Description',
    'Material' => 'Material',
    'Tanks' => 'Tanks',
    'MaterialHandling' => 'MaterialHandling',
    'Thumbnail' => 'Photo',
    'URLSegment' => 'URLSegment'
    ), // Headings
    'getCMSFields_forPopup'// Detail fields (function name or FieldSet object)
    // Filter clause
    // Sort clause
    // Join clause
    );
    $datamanager->setPopupWidth('675');

    $fields->addFieldToTab("Root.Content.Equipment",$datamanager);
    return $fields;
    }

    FileDOM example field definition:

    $resourceUploadField = new FileUploadField(
    'Attachment',
    'Upload a File',
    array(
    'buttonText' => 'Upload a PDF'
    )
    );

    $resourceUploadField->setuploadFolder('PDFs/MSDS');
    $resourceUploadField->setFileTypes(array('pdf'));
    $resourceUploadField->allowFolderSelection = false;


    File DOM definition:

    {
    $fields = parent::getCMSFields();
    $manager = new FileDataObjectManager(
    $this, // Controller
    'Resources', // Source name
    'Resource', // Source class
    'Attachment', // File name on DataObject
    array(
    'Name' => 'Name',
    ), // Headings
    'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
    // Filter clause
    // Sort clause
    // Join clause
    );

    $manager->setuploadFolder('PDFs/MSDS'); //This actually works in Uploadify when put here, the other settings dont
    $fields->addFieldToTab("Root.Content.Resources",$manager);
    return $fields;
    }

    Thanks in advance!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify: features not working with FileDOM, working with DOM Link to this post

    I think the only to properties that FileDOM will forward to the Uploadify fields are the upload folder and the allowed file types. It looks like you want "allowFolderSelection" to also be one of those properties?

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Uploadify: features not working with FileDOM, working with DOM Link to this post

    Exactly. I want to specify the upload folder and then make it so that it cannot be changed. Also, I want to only allow the user to upload pdf files. I think I could still do this at the fileDom level instead of at the uploadify field level... I was just trying to follow the UsedEquip DOM as an example for consistency. Are these things possible?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Uploadify: features not working with FileDOM, working with DOM Link to this post

    You have to update it in two places..

    $manager->setUploadFolder()
    $manager->setAllowedFileTypes()

    Will affect the upload interface on the "add" action.

    In the getCMSFields() function for your DataObject, you'll need to update the Uploadify fields for the "edit" action:

    $uploader->setUploadFolder()
    $uploader->setAllowedFileTypes();

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Uploadify: features not working with FileDOM, working with DOM Link to this post

    OK, the allowed types and setting the upload folder is working now but the "allowFolderSelection" even when set to false in both places still lets you change the folder both when updating and adding.

    932 Views
Page: 1
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.