Skip to content

Commit

Permalink
fix(filefield): rebuild uploads for answer edition
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed May 4, 2023
1 parent 768cd46 commit 4f1cdf6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions inc/field/filefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ public function getRenderedHtml($domain, $canEdit = true): string {
return $html;
}

if (is_array($this->uploadData) && count($this->uploadData) > 0) {
$html = '';
$doc = new Document();
foreach ($this->uploadData as $item) {
if (is_numeric($item) && $doc->getFromDB($item)) {
$prefix = uniqid('', true);
$filename = $prefix . $doc->fields['filename'];
if (!copy(GLPI_DOC_DIR . '/' . $doc->fields['filepath'], GLPI_TMP_DIR . '/' . $filename)) {
continue;
}
$key = 'formcreator_field_' . $this->getQuestion()->getID();
$this->uploads['_' . $key][] = $filename;
$this->uploads['_prefix_' . $key][] = $prefix;
$this->uploads['_tag_' . $key][] = $doc->fields['tag'];
}
}
}

return Html::file([
'name' => 'formcreator_field_' . $this->question->getID(),
'display' => false,
Expand Down

0 comments on commit 4f1cdf6

Please sign in to comment.