Bug #89730

The EmailFinisher does not parse variables before assigning to the view

Added by DANIEL Rémy 7 months ago. Updated 6 months ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Target version:
-
Start date:
2019-11-21
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:
Remote Sprint

Description

Hello

Context

Following this guide: [https://docs.typo3.org/c/typo3/cms-form/8.7/en-us/Concepts/FrontendRendering/Index.html#concepts-frontendrendering-codecomponents-customfinisherimplementations-finishercontext-sharedatabetweenfinishers]

I am trying to get a variable from a previous finisher and to set it in the variables of a next finisher.
Here is the summary of the finishers in the form definition:

finishers:
-
    identifier: SaveToDatabase
    options:
       table: 'tx_myext_domain_model_offer'
       mode: 'insert'
       ...
-
    identifier: EmailFinisher
    options:
      ...
      variables:
        recordUid: '{SaveToDatabase.insertedUids.0}'

Issue

In the fluid template of the email, the value of the variable {recordUid} is SaveToDatabase.insertedUids.0.

Expected

In the fluid template of the email, the value of the variable {recordUid} should be the UID of the record created by the finisher SaveToDatabase.

Solution

In \TYPO3\CMS\Form\Domain\Finishers\EmailFinisher::initializeStandaloneView(), $this->parseOption should be used instead of directly accessing $this->options.

Reproduced on TYPO3 8 and 9.

Associated revisions

Revision bc06b1bf (diff)
Added by Mathias Brodala 7 months ago

[TASK] Document variables assigned to mail templates

Resolves: #89730
Releases: master, 9.5
Change-Id: I1754168d86cd9d69d866accee9fc042f8e967490
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62363
Tested-by: TYPO3com <>
Tested-by: Björn Jacob <>
Tested-by: Oliver Bartsch <>
Tested-by: Benni Mack <>
Reviewed-by: Björn Jacob <>
Reviewed-by: Oliver Bartsch <>
Reviewed-by: Benni Mack <>

Revision 7d185b3a (diff)
Added by Bjoern Jacob 7 months ago

[TASK] Document variables assigned to mail templates

Resolves: #89730
Releases: master, 9.5
Change-Id: I1754168d86cd9d69d866accee9fc042f8e967490
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62290
Tested-by: Björn Jacob <>
Tested-by: TYPO3com <>
Tested-by: Benni Mack <>
Reviewed-by: Björn Jacob <>
Reviewed-by: Benni Mack <>

History

#1 Updated by DANIEL Rémy 7 months ago

  • Description updated (diff)

#2 Updated by Bjoern Jacob 7 months ago

  • Sprint Focus set to Remote Sprint

#3 Updated by Mathias Brodala 7 months ago

  • Status changed from New to In Progress
  • Assignee set to Mathias Brodala

Actually the variable is not necessary here since the template of the EmailFinisher also gets the FinisherVariableProvider assigned as finisherVariableProvider variable.

Then you could access your value as desired.

#4 Updated by Gerrit Code Review 7 months ago

  • Status changed from In Progress to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62363

#5 Updated by Vasyl Mosiychuk 7 months ago

Daniel is right, I can get this value '{SaveToDatabase.insertedUids.0}' only in "subject email" but in the "body email" I can not get this value... this can be very helpful

#6 Updated by Mathias Brodala 7 months ago

Vasyl Mosiychuk wrote:

Daniel is right, I can get this value '{SaveToDatabase.insertedUids.0}' only in "subject email" but in the "body email" I can not get this value... this can be very helpful

It actually works in your mail template:

{finisherVariableProvider.SaveToDatabase.insertedUids.0}

#7 Updated by DANIEL Rémy 7 months ago

The example at the end of https://docs.typo3.org/c/typo3/cms-form/master/en-us/I/Concepts/Finishers/Index.html?highlight=share#share-data-between-finishers suggested to me that a variable pushed into the FinisherVariableProvider is directly usable in the next finishers.

I think I misunderstood how it works.
The other finishers have to "parse" the variable's value before using it, because it is not automatically parsed.
And in the case of the EmailFinisher, I can access directly the finisherVariableProvider from the fluid template.

It is not really user-friendly api, some variables are parsed, some aren't.

#8 Updated by Gerrit Code Review 7 months ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62290

#9 Updated by Mathias Brodala 7 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#10 Updated by Gerrit Code Review 7 months ago

  • Status changed from Resolved to Under Review

Patch set 2 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62290

#11 Updated by Bjoern Jacob 7 months ago

  • Status changed from Under Review to Resolved

#12 Updated by Benni Mack 6 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF