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.

All other Modules /

Discuss all other Modules here.

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

Display Logic module not working with file uploads


Go to End


2 Posts   1467 Views

Avatar
darjus01

Community Member, 6 Posts

28 January 2015 at 10:09pm

Hi, I am using display logic module for SS https://github.com/unclecheese/silverstripe-display-logic
it work good but has one problem it not worting with file upload fields. Does anybody face this?
From firebug it seams that js ignoring file upload input container, I tryied different variations from simple displayif, to putting all in LogicWrapper same results with file upload fields.
Here is my basic code:

public function getCMSFields() {
        $fields = parent::getCMSFields();
        $fields = new FieldList(
            DropdownField::create('ProductID', 'Product', Product::get()->map('ID', 'Title'))->setEmptyString('(Select one)'),
            $mainCategory = DropdownField::create('CategoryID', 'Category', Category::get()->map('ID', 'Title'))->setEmptyString('(Select one)'),
            $mainLocation = DropdownField::create('LocationID', 'Location', Location::get()->map('ID', 'Title'))->setEmptyString('(Select one)'),
            $mainTitle = TextField::create('Title', 'Title'),
            $mainFile = UploadField::create('File', 'File')->setFolderName('Uploads/Files')->setAllowedExtensions(array('odt', 'jpg', 'jpeg', 'png', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pdf')),
            
            $addMoreDocSwicher = CheckboxField::create('HaveChild', 'I want to upload additional document'),
                
            // second fields hidden    
            $secondaryDocument_category = DropdownField::create('CategoryID2', 'Category', Category::get()->map('ID', 'Title'))->setEmptyString('(Select one)'),
            $secondaryDocument_location = DropdownField::create('LocationID2', 'Location', Location::get()->map('ID', 'Title'))->setEmptyString('(Select one)'),
            $secondaryDocument_files = UploadField::create('File2', 'File'),
            $secondaryDocument_title = TextField::create('Title2', 'Title')
            
         );
        
        $mainCategory->displayIf("ProductID")->isNotEqualTo("");
        $mainLocation->displayIf("ProductID")->isNotEqualTo("")->andIf("ProductID")->isNotEqualTo(3);
        $mainTitle->displayIf("ProductID")->isNotEqualTo("");
        $mainFile->displayIf("ProductID")->isNotEqualTo("");
        
        $addMoreDocSwicher->displayIf("ProductID")->isEqualTo(5)->orIf("ProductID")->isEqualTo(6);
        $secondaryDocument_category->displayIf('HaveChild')->isChecked();
        $secondaryDocument_location->displayIf('HaveChild')->isChecked();
        $secondaryDocument_title->displayIf('HaveChild')->isChecked();
        $secondaryDocument_files->displayIf('HaveChild')->isChecked();
        
        return $fields;
    }

Any ideas? Thanks.

Avatar
darjus01

Community Member, 6 Posts

3 February 2015 at 9:48pm

updated SS version from 3.1.6 to 3.1.9 and used not master version of display logic module, and it started to work perfecly