Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save default DownloadBehaviour on a DMSDocument when initially uploading a new one #214

Merged

Conversation

@davidcollins4481
Copy link

commented Jul 5, 2018

I needed to change the default to be "open" rather than "download". I set this

DMSDocument:
  default_download_behaviour: 'open'

but noticed that when uploading new documents the default state from the enum of the field was written rather than the default option set in my config. I added code in onBeforeWrite to write the default if set.

$possibleBehaviors = $this->dbObject('DownloadBehavior')
->enumValues();
$behavior = $possibleBehaviors[$defaultDownloadBehaviour];

This comment has been minimized.

Copy link
@dhensby

dhensby Jul 5, 2018

Member

you need an isset or !empty or array_key_exists check here

This comment has been minimized.

Copy link
@davidcollins4481
@dhensby

This comment has been minimized.

Copy link
Member

commented Jul 5, 2018

When you upload the document in the CMS is the field value not as per the config? I'm confused as to why this isn't written if the current logic sets the correct value of the CMS field

@davidcollins4481

This comment has been minimized.

Copy link
Author

commented Jul 6, 2018

When you upload the document in the CMS is the field value not as per the config?

Correct. When adding a document in the "Documents" tab on a page, the value that always gets set by default is the default value of the enum

        "DownloadBehavior" => 'Enum(array("open","download"), "download")',

The check of the config option only occurs when viewing the document after upload. I tested this on 2.2.0 and 1.x.

Dave Collins
Save default DownloadBehaviour on a DMSDocument when initially upload…
…ing a new one

- array key check for behavior before using
@dhensby

This comment has been minimized.

Copy link
Member

commented Jul 6, 2018

The check of the config option only occurs when viewing the document after upload. I tested this on 2.2.0 and 1.x.

Ahah! I see.

@dhensby dhensby merged commit c0fbe98 into silverstripe:master Jul 6, 2018

2 checks passed

Scrutinizer No new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.