From 3e33ff6723f24f2b6ed7d2e5731269bbf787e196 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Sun, 24 Apr 2016 20:50:14 +0000 Subject: [PATCH] files: FileUploadWidget render Use file id instead of attachment id to unset new Get new files objects as array --- include/class.forms.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index 661822005..627cd5a72 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -3668,17 +3668,19 @@ class FileUploadWidget extends Widget { $maxfilesize = ($config['size'] ?: 1048576) / 1048576; $files = $F = array(); $new = array_fill_keys($this->field->getClean(), 1); - foreach ($attachments as $f) { - $F[] = $f->file; - unset($new[$f->id]); + foreach ($attachments as $a) { + $F[] = $a->file; + unset($new[$a->file_id]); } // Add in newly added files not yet saved (if redisplaying after an // error) if ($new) { $F = array_merge($F, AttachmentFile::objects() ->filter(array('id__in' => array_keys($new))) - ->all()); + ->all() + ); } + foreach ($F as $file) { $files[] = array( 'id' => $file->getId(), -- GitLab