Closed kinglozzer closed 8 years ago
If anyone is stuck and happens to stumble upon this issue, I found a workaround (one that could be used to patch this). I needed to customise DMSUploadField
quite a bit, so I subclassed it and used Injector to use my class instead.
The solution I came up with was to create my own ItemHandler
and overload UploadField_ItemHandler::EditForm()
:
public function EditForm() {
$file = $this->getItem();
// Get form components
$fields = $this->parent->getDMSFileEditFields($file);
$actions = $this->parent->getDMSFileEditActions($file);
$validator = $this->parent->getDMSFileEditValidator($file);
$form = new Form(
$this,
__FUNCTION__,
$fields,
$actions,
$validator
);
$form->loadDataFrom($file);
$form->addExtraClass('small');
return $form;
}
Where getDMSFileEditFields
, getDMSFileEditActions
and getDMSFileEditValidator
are methods I added to my subclass of DMSUploadField
(just copied and pasted from UploadField
with the type hinting removed).
Has there been any progress on properly fixing this? @dhensby
@kinglozzer ?
@jaedb to answer more explicitly, I don't have a clue - I'm only lightly involved in maintaining DMS and don't actually use it in production.
This issue is coming up to 2 years old so you'd like to think it's fixed, but I guess you're asking because it's not?
I'd have thought this is more an underlying framework issue than a DMS one, but I haven't looked into it, I'm afraid.
@dhensby I suspect the issue has flown under the radar because it's not causing critical errors. However I suspect the later versions of Silverstripe are becoming more sensitive to the issue. SS 3.3.2 + DMS just don't work well at all together.
It seems to me that the root cause is a combination of UploadField
wanting a File
object, and DMSDocument
extending DataObject
. This means DMS is always going to require hack fixes until it extends the File
object or UploadField
becomes more flexible.
Sorry, my memory of this module is really patchy! I think you’re correct @jaedb - the issue is to do with UploadField
expecting an instance of File
- hence why I had to remove the type-hinting by naming the validator/action/field methods something else :/
I have no idea how best to approach fixing this, though...
I think @benmanu has a fix at https://github.com/benmanu/silverstripe-dms/commit/a5e2d29e9c80d7eea9f6825764c50b8ea360e9ca?
PR @benmanu?
When attaching files to a page using the “AssetUploadField” view, if you click the “Edit” button after uploading you’ll get a server error:
I’m not sure if this can actually be fixed in this module. Screenshot attached of the view I’m referring to.