silverstripe / silverstripe-dms

Adds a Document Management System to Silverstripe
BSD 3-Clause "New" or "Revised" License
40 stars 52 forks source link

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

Closed davidcollins4481 closed 6 years ago

davidcollins4481 commented 6 years ago

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.

dhensby commented 6 years ago

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 commented 6 years ago

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.

dhensby commented 6 years ago

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.