Bug #89730
closedThe EmailFinisher does not parse variables before assigning to the view
100%
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.
Updated by Mathias Brodala over 4 years 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.
Updated by Gerrit Code Review over 4 years 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
Updated by Vasyl Mosiychuk over 4 years 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
Updated by Mathias Brodala over 4 years 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}
Updated by Rémy DANIEL over 4 years 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.
Updated by Gerrit Code Review over 4 years 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
Updated by Mathias Brodala over 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset bc06b1bffb88746458820e0bfa2ffdaa09bfa935.
Updated by Gerrit Code Review over 4 years 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
Updated by Björn Jacob over 4 years ago
- Status changed from Under Review to Resolved
Applied in changeset 7d185b3a7aa293723b15fbac577fb9194e4cdbef.