Skip to content

Commit

Permalink
MDL-28099 fixes issue with filepicker and element names with index no…
Browse files Browse the repository at this point in the history
…t passing

value for draftitemid.
  • Loading branch information
jamiepratt committed Jun 29, 2011
1 parent 3552484 commit b1eca34
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/form/filepicker.php
Expand Up @@ -112,9 +112,13 @@ function toHtml() {
function exportValue(&$submitValues, $assoc = false) { function exportValue(&$submitValues, $assoc = false) {
global $USER; 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 // make sure max one file is present and it is not too big
if (!empty($submitValues[$this->_attributes['name']])) { if (!is_null($draftitemid)) {
$draftitemid = $submitValues[$this->_attributes['name']];
$fs = get_file_storage(); $fs = get_file_storage();
$usercontext = get_context_instance(CONTEXT_USER, $USER->id); $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) { if ($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id DESC', false)) {
Expand All @@ -128,10 +132,7 @@ function exportValue(&$submitValues, $assoc = false) {
$file->delete(); $file->delete();
} }
} }
return array($this->_attributes['name'] => $submitValues[$this->_attributes['name']]);
} else {
return null;
} }

return $this->_prepareValue($draftitemid, $assoc);
} }
} }

0 comments on commit b1eca34

Please sign in to comment.