From this link https://docs.typo3.org/c/typo3/cms-form/main/en-us/E/Finishers/Index.html it says Finishers are executed in the order defined in your form definition.
which I believe is the yaml file where I define everything related to my form, in my case it's contactUs.form.yaml
. In it I have defined 3 finishers:
finishers:
-
options: &cyberImpactFinisherOptions
message: 'Merci pour votre message.'
templateRootPaths:
100: 'EXT:site_pgq/Resources/Private/Templates/Partial/'
templateName: ContactThankYou
identifier: CyberImpactFinisher
-
options: &emailToReceiverOptions
subject: 'Nouveau message du site PGQ.ca'
recipients:
test@pgq.ca: test
senderAddress: fdsfsa@ffds.com
senderName: fdsfsa
addHtmlPart: true
attachUploads: true
templateName: ContactUsForm
translation:
language: Default
useFluidEmail: true
title: 'Nouveau message!'
templateRootPaths:
100: 'EXT:site_pgq/Resources/Private/Templates/Email/'
partialRootPaths:
100: 'EXT:site_pgq/Resources/Private/Partials/Email/'
layoutRootPaths:
100: 'EXT:site_pgq/Resources/Private/Layouts/Email/'
identifier: EmailToReceiver
-
identifier: FormToDatabase
You can see the order is: CyberImpactFinisher > EmailToReceiver > FormToDatabase
But when I output the result of $this->finisherContext->getFormRuntime()->getFormDefinition()->getFinishers();
The order I get is EmailToReceiver > CyberImpactFinisher > FormToDatabase.
I believe the order ofgetFinishers()
is the real one because if I do a $this->finisherContext->cancel();
in the CyberImpactFinisher, the email is sent but the form is not saved in the database.
I would like to change the order of my finishers so that when I do $this->finisherContext->cancel();
in the CyberImpactFinisher, the email will not be sent and the info not saved in the database, but I can't find how to change the order of the finishers.
Any help is appreciated, thank you!
Ok I found the solution! The finishers in my form.yaml
were properly ordered but the problem was that I used variants in my form and to keep using finishers you have to redefine them in the variant, and that's where my order was wrong. So fixing the order in my variants fixed my problem.