symfony condition syntax for on/off mail to sender by checkbox in frontend

118 views Asked by At

Before the update to TYPO3 9.5 I used the following condition syntax in setup.typoscript to enable sending an email to the sender using a checkbox in the frontend form:

[globalString = GP:tx_powermail_pi1|field|emailanabsender|0 = ]
    plugin.tx_powermail.settings.setup.sender.enable = 0
[else]
    plugin.tx_powermail.settings.setup.sender.enable = 1
[global]

What should the symfony condition syntax look like for this purpose?

According to my logic, the following should work, but it does not:

[traverse(request.getParsedBody(), 'tx_powermail_pi1/field/emailanabsender/0')]
    plugin.tx_powermail.settings.setup.sender.enable = 1
[else]
    plugin.tx_powermail.settings.setup.sender.enable = 0
[global]

Can anyone help me with this?

2

There are 2 answers

0
Alex Kellner On

What about this:

[traverse(request.getQueryParams(), 'tx_powermail_pi1/field/emailanansender/0') > 0]
0
boogie76 On

I got It. The correct syntax for TYPO3 >= 9 is:

[traverse(request.getParsedBody(), 'tx_powermail_pi1/field/emailanabsender/0') == '']
    plugin.tx_powermail.settings.setup.sender.enable = 0
[else]
    plugin.tx_powermail.settings.setup.sender.enable = 1
[global]

The docs says: "In case the path is not found in the array, an empty string is returned."

Data from the POST request can be read with request.getParsedBody(), and if the checkbox is unchecked, then it's missing in the POST-request.