Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-28099 fixes issue with filepicker and element names with index no…

…t passing

value for draftitemid.
  • Loading branch information...
commit b1eca34453a2a55b230a8befeabb31aba85e15cb 1 parent 3552484
James Pratt authored June 29, 2011

Showing 1 changed file with 7 additions and 6 deletions. Show diff stats Hide diff stats

  1. 13  lib/form/filepicker.php
13  lib/form/filepicker.php
@@ -112,9 +112,13 @@ function toHtml() {
112 112
     function exportValue(&$submitValues, $assoc = false) {
113 113
         global $USER;
114 114
 
  115
+        $draftitemid = $this->_findValue($submitValues);
  116
+        if (null === $draftitemid) {
  117
+            $draftitemid = $this->getValue();
  118
+        }
  119
+
115 120
         // make sure max one file is present and it is not too big
116  
-        if (!empty($submitValues[$this->_attributes['name']])) {
117  
-            $draftitemid = $submitValues[$this->_attributes['name']];
  121
+        if (!is_null($draftitemid)) {
118 122
             $fs = get_file_storage();
119 123
             $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
120 124
             if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) {
@@ -128,10 +132,7 @@ function exportValue(&$submitValues, $assoc = false) {
128 132
                     $file->delete();
129 133
                 }
130 134
             }
131  
-            return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]);
132  
-        } else {
133  
-            return null;
134 135
         }
135  
-
  136
+        return $this->_prepareValue($draftitemid, $assoc);
136 137
     }
137 138
 }

0 notes on commit b1eca34

Please sign in to comment.
Something went wrong with that request. Please try again.