The HMAC of the form could not be validated

Viewed 1478

We are using Forms for different contact options. But as Forms do not have a lot of customisation possibilities we have developed an extension that modifies finishers. One of those is to change "send to" address accordingly to what option it has been selected in dropdown.

As finisher we have this input

namespace Sunlime\Mappingemailfinisher\Domain\Finishers;

use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;

class MapValues extends AbstractFinisher {
    protected function executeInternal() {
        $stateToRecipientMap = [
      'Option 1'      => 'option 1 email',
      'Option 2'      => 'option 2 email',
      'Option 3'      => 'option 3 email',
      'Option 4'      => 'option 4 email',
        ];
        $errorRecipientAddress = 'fallback email';

        $formValues = $this->finisherContext->getFormValues();
        $context = $this->finisherContext->getFinisherVariableProvider();

        if(is_array($formValues) &&
           array_key_exists($formValues['singleselect-2'], $stateToRecipientMap) &&
           !empty($stateToRecipientMap[$formValues['singleselect-2']])) {

            $context->add($this->shortFinisherIdentifier, 'recipientAddress', $stateToRecipientMap[$formValues['singleselect-2']]);

        } else {

            $context->add($this->shortFinisherIdentifier, 'recipientAddress', $errorRecipientAddress);

        }
    }
}

And in form yaml we have then

properties:
          options:
            'Option 1': 'Option 1'
            'Option 2': 'Option 2'
            'Option 3': 'Option 3'
            'Option 4': 'Option 4'
          fluidAdditionalAttributes:

That outputs a dropdown field. Now in typo3 log I see an error

Core: Exception handler (WEB): Uncaught TYPO3 Exception: #1581862822: The HMAC of the form could not be validated. | TYPO3\CMS\Core\Error\Http\BadRequestException thrown in file /www/home/typo3_src-9.5.19/typo3/sysext/extbase/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php in line 136.

Google search doesn't return any useful information. I am not sure if this error has something to do with our custom finishers but it obviously has something to do with forms. Can someone maybe help me to solve this error? Thx

0 Answers
Related