Bug #87722

Forms: Error message of Advanced password is not translatable

Added by Daniel Koether about 1 month ago. Updated 17 days ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2019-02-15
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Hello everyone,

if you type two different passwords in the advanced password field of EXT:form the error message is english because its hardcoded in Class FormElementHook.
See: https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/form/Classes/Hooks/FormElementHooks.php

There is no inherited function like translateErrorMessage in AbstractValidator class. Please provide this translation possibility also in Hooks:

class FormElementHooks
{

    /**
     * This hook is invoked by the FormRuntime for each form element
     * **after** a form page was submitted but **before** values are
     * property-mapped, validated and pushed within the FormRuntime's `FormState`.
     *
     * @param FormRuntime $formRuntime
     * @param RenderableInterface $renderable
     * @param mixed $elementValue submitted value of the element *before post processing*
     * @param array $requestArguments submitted raw request values
     * @return mixed
     * @see FormRuntime::mapAndValidate()
     * @internal
     */
    public function afterSubmit(FormRuntime $formRuntime, RenderableInterface $renderable, $elementValue, array $requestArguments = [])
    {
        if ($renderable->getType() === 'AdvancedPassword') {
            if ($elementValue['password'] !== $elementValue['confirmation']) {
                $processingRule = $renderable->getRootForm()->getProcessingRule($renderable->getIdentifier());
                $processingRule->getProcessingMessages()->addError(
                    GeneralUtility::makeInstance(ObjectManager::class)
                        ->get(Error::class,
                            $this->translateErrorMessage(
                                'translation.key',
                                'form'
                            ), 1334768052)
                );
            }
            $elementValue = $elementValue['password'];
        }

        return $elementValue;
    }

    /**
     * Wrap static call to LocalizationUtility to simplify unit testing
     *
     * @param string $translateKey
     * @param string $extensionName
     * @param array $arguments
     *
     * @return string|null
     */
    protected function translateErrorMessage($translateKey, $extensionName, $arguments = [])
    {
        return \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
            $translateKey,
            $extensionName,
            $arguments
        );
    }

Thanks in advance!

Best regards,
Daniel

History

#1 Updated by Susanne Moog 17 days ago

  • Category set to Form Framework

Also available in: Atom PDF