简体   繁体   中英

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

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?

What about this:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM