Skip to content

Commit 753b423

Browse files
committed
fix(targetticket,targetchange): file dispatch accross several targets broken
without this fix all file uploads were added to all targets, ignoring the absence of tag of the file questions Signed-off-by: Thierry Bugier <tbugier@teclib.com>
1 parent 6392cdf commit 753b423

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

inc/formanswer.class.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,19 +1105,16 @@ public function parseTags(string $content, PluginFormcreatorTargetInterface $tar
11051105
}
11061106

11071107
$content = str_replace('##question_' . $questionId . '##', Toolbox::addslashes_deep($name), $content);
1108-
$content = str_replace('##answer_' . $questionId . '##', Toolbox::addslashes_deep($value), $content);
1109-
if ($target !== null) {
1110-
foreach ($this->questionFields[$questionId]->getDocumentsForTarget() as $documentId) {
1111-
$target->addAttachedDocument($documentId);
1112-
}
1113-
}
11141108
if ($question->fields['fieldtype'] === 'file') {
11151109
if (strpos($content, '##answer_' . $questionId . '##') !== false) {
1116-
if (!is_array($value)) {
1117-
$value = [$value];
1110+
if ($target !== null) {
1111+
foreach ($this->questionFields[$questionId]->getDocumentsForTarget() as $documentId) {
1112+
$target->addAttachedDocument($documentId);
1113+
}
11181114
}
11191115
}
11201116
}
1117+
$content = str_replace('##answer_' . $questionId . '##', Toolbox::addslashes_deep($value), $content);
11211118

11221119
if ($this->questionFields[$questionId] instanceof DropdownField) {
11231120
$content = $this->questionFields[$questionId]->parseObjectProperties($field->getValueForDesign(), $content);

0 commit comments

Comments
 (0)