Skip to content

Commit

Permalink
fix(notificationtargetformanswer): tags not fully rendered
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jan 29, 2021
1 parent 58c2dd1 commit 9c2620f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ public function post_purgeItem() {
* @param boolean $richText Disable rich text mode for field rendering
* @return string Parsed string with tags replaced by form values
*/
public function parseTags($content, PluginFormcreatorTargetInterface $target, $richText = false) {
public function parseTags($content, PluginFormcreatorTargetInterface $target = null, $richText = false) {
// Prepare all fields of the form
$form = $this->getForm();
$this->getQuestionFields($form->getID());
Expand All @@ -1105,8 +1105,10 @@ public function parseTags($content, PluginFormcreatorTargetInterface $target, $r

$content = str_replace('##question_' . $questionId . '##', Toolbox::addslashes_deep($name), $content);
$content = str_replace('##answer_' . $questionId . '##', Toolbox::addslashes_deep($value), $content);
foreach ($this->questionFields[$questionId]->getDocumentsForTarget() as $documentId) {
$target->addAttachedDocument($documentId);
if ($target !== null) {
foreach ($this->questionFields[$questionId]->getDocumentsForTarget() as $documentId) {
$target->addAttachedDocument($documentId);
}
}
if ($question->fields['fieldtype'] === 'file') {
if (strpos($content, '##answer_' . $questionId . '##') !== false) {
Expand Down
2 changes: 1 addition & 1 deletion inc/notificationtargetformanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function addDataForTemplate($event, $options = []) {
$this->data['##formcreator.form_requester##'] = $requester->getName();
$this->data['##formcreator.form_validator##'] = $validator->getName();
$this->data['##formcreator.form_creation_date##'] = Html::convDateTime($this->obj->fields['request_date']);
$this->data['##formcreator.form_full_answers##'] = $this->obj->getFullForm();
$this->data['##formcreator.form_full_answers##'] = $this->obj->parseTags($this->obj->getFullForm());
$this->data['##formcreator.validation_comment##'] = $this->obj->fields['comment'];
$this->data['##formcreator.validation_link##'] = $link;
$this->data['##formcreator.request_id##'] = $this->obj->fields['id'];
Expand Down

0 comments on commit 9c2620f

Please sign in to comment.