Consent finisher¶
A new finisher Consent
is available in the backend form editor.
It saves all submitted form data in the database and sends a
corresponding mail to either approve or dismiss a given consent.
Tip
The last inserted consent is populated with the finisher variable
provider. It can be accessed as {Consent.lastInsertedConsent}
in
the .form.yaml
configuration.
Example¶
finishers:
-
identifier: Consent
options:
subject: 'Please approve your subscription'
recipientAddress: '{email}'
recipientName: '{first-name} {last-name}'
senderAddress: ''
senderName: ''
approvalPeriod: '86400'
showDismissLink: true
confirmationPid: '277'
storagePid: '276'
-
identifier: SaveToDatabase
options:
table: tx_myextension_domain_model_subscription
mode: insert
databaseColumnMappings:
consent:
# References the consent uid
value: '{Consent.lastInsertedConsent.uid}'
See also
Read more about all available finisher options in Form finisher configuration.
Invoke finishers on consent approval or dismissal¶
After a user has given or revoked consent, it is often necessary to execute certain form finishers. For example, to send an admin email or redirect to a specific page.
To achieve this, after the user gives or revokes consent, the originally
completed form is resubmitted. During this resubmission of the form, the
selected finishers can now be overwritten using the isConsentApproved()
or isConsentDismissed()
conditions in a form variant.
Requirements¶
The following requirements must be met for the form to be resubmitted:
Form variant at the root level of the form must exist
Form variant must redefine the finishers used
Conditions
isConsentApproved()
orisConsentDismissed()
must exist in the variant
Example¶
The following form variant is stored directly on the root level of the
form definition (that is, your .form.yaml
file). It specifies the
form finishers to be executed in case of successful approval by the user.
variants:
-
identifier: post-consent-approval-variant-1
condition: 'isConsentApproved()'
finishers:
-
identifier: EmailToReceiver
options:
# ...
-
identifier: Redirect
options:
# ...
In this example, an admin email would be sent after the consent has been given and a redirect to the configured confirmation page would take place.
The same behavior can be achieved in case the user revokes his consent. The
condition isConsentDismissed()
must then be used instead.