Skip to content

Commit 4f1cdf6

Browse files
committed
fix(filefield): rebuild uploads for answer edition
1 parent 768cd46 commit 4f1cdf6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

inc/field/filefield.class.php

+18
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,24 @@ public function getRenderedHtml($domain, $canEdit = true): string {
8888
return $html;
8989
}
9090

91+
if (is_array($this->uploadData) && count($this->uploadData) > 0) {
92+
$html = '';
93+
$doc = new Document();
94+
foreach ($this->uploadData as $item) {
95+
if (is_numeric($item) && $doc->getFromDB($item)) {
96+
$prefix = uniqid('', true);
97+
$filename = $prefix . $doc->fields['filename'];
98+
if (!copy(GLPI_DOC_DIR . '/' . $doc->fields['filepath'], GLPI_TMP_DIR . '/' . $filename)) {
99+
continue;
100+
}
101+
$key = 'formcreator_field_' . $this->getQuestion()->getID();
102+
$this->uploads['_' . $key][] = $filename;
103+
$this->uploads['_prefix_' . $key][] = $prefix;
104+
$this->uploads['_tag_' . $key][] = $doc->fields['tag'];
105+
}
106+
}
107+
}
108+
91109
return Html::file([
92110
'name' => 'formcreator_field_' . $this->question->getID(),
93111
'display' => false,

0 commit comments

Comments
 (0)