From b1eca34453a2a55b230a8befeabb31aba85e15cb Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Wed, 29 Jun 2011 18:39:15 +0700 Subject: [PATCH] MDL-28099 fixes issue with filepicker and element names with index not passing value for draftitemid. --- lib/form/filepicker.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/form/filepicker.php b/lib/form/filepicker.php index c5af6e18866..b7242489ae6 100644 --- a/lib/form/filepicker.php +++ b/lib/form/filepicker.php @@ -112,9 +112,13 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { function exportValue(&$submitValues, $assoc = false) { global $USER; + $draftitemid = $this->_findValue($submitValues); + if (null === $draftitemid) { + $draftitemid = $this->getValue(); + } + // make sure max one file is present and it is not too big - if (!empty($submitValues[$this->_attributes['name']])) { - $draftitemid = $submitValues[$this->_attributes['name']]; + if (!is_null($draftitemid)) { $fs = get_file_storage(); $usercontext = get_context_instance(CONTEXT_USER, $USER->id); if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) { @@ -128,10 +132,7 @@ class MoodleQuickForm_filepicker extends HTML_QuickForm_input { $file->delete(); } } - return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]); - } else { - return null; } - + return $this->_prepareValue($draftitemid, $assoc); } }