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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Uploadify: features not working with FileDOM, working with DOM


Go to End


5 Posts   1370 Views

Avatar
theoldlr

Community Member, 103 Posts

20 October 2010 at 6:00am

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!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 October 2010 at 8:26am

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

Avatar
theoldlr

Community Member, 103 Posts

20 October 2010 at 8:48am

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?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

20 October 2010 at 9:34am

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

Avatar
theoldlr

Community Member, 103 Posts

21 October 2010 at 1:40am

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.