Skip to content
Snippets Groups Projects
Commit 8553c2fb authored by JediKev's avatar JediKev
Browse files

oops: Class GenericAttachment Not Found

This addresses an issue introduced with 4426 that references an undefined
class.
parent 33a7677c
Branches
Tags
No related merge requests found
......@@ -3909,26 +3909,14 @@ class FileUploadWidget extends Widget {
$config = $this->field->getConfiguration();
$name = $this->field->getFormName();
$id = substr(md5(spl_object_hash($this)), 10);
$attachments = $this->field->getAttachments();
$mimetypes = array_filter($config['__mimetypes'],
function($t) { return strpos($t, '/') !== false; }
);
$maxfilesize = ($config['size'] ?: 1048576) / 1048576;
$files = array();
$new = array_fill_keys($this->field->getClean(), 1);
foreach ($attachments as $a) {
unset($new[$a->file_id]);
}
// Add in newly added files not yet saved (if redisplaying after an
// error)
if ($new) {
$attachments = array_merge($attachments, GenericAttachment::objects()
->filter(array('file_id__in' => array_keys($new)))
->all()
);
}
foreach ($attachments as $att) {
foreach ($this->field->getAttachments() as $att) {
unset($new[$att->file_id]);
$files[] = array(
'id' => $att->file->getId(),
'name' => $att->getFilename(),
......@@ -3937,6 +3925,25 @@ class FileUploadWidget extends Widget {
'download_url' => $att->file->getDownloadUrl(),
);
}
// Add in newly added files not yet saved (if redisplaying after an
// error)
if ($new) {
$F = AttachmentFile::objects()
->filter(array('id__in' => array_keys($new)))
->all();
foreach ($F as $f) {
$f->tmp_name = $new[$f->getId()];
$files[] = array(
'id' => $f->getId(),
'name' => $f->getName(),
'type' => $f->getType(),
'size' => $f->getSize(),
'download_url' => $f->getDownloadUrl(),
);
}
}
?><div id="<?php echo $id;
?>" class="filedrop"><div class="files"></div>
<div class="dropzone"><i class="icon-upload"></i>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment