Project

General

Profile

Actions

Bug #87722

closed

Forms: Error message of Advanced password is not translatable

Added by Daniel Hettler about 5 years ago. Updated almost 5 years ago.

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

100%

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

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

Actions #1

Updated by Susanne Moog about 5 years ago

  • Category set to Form Framework
Actions #2

Updated by Björn Jacob about 5 years ago

  • Sprint Focus set to Remote Sprint
Actions #3

Updated by Petra Neumann almost 5 years ago

  • Status changed from New to In Progress
  • Assignee set to Petra Neumann
  • Target version set to Candidate for Major Version
Actions #4

Updated by Petra Neumann almost 5 years ago

  • Status changed from In Progress to New
  • Assignee deleted (Petra Neumann)
  • Target version deleted (Candidate for Major Version)
Actions #5

Updated by Michael Waack almost 5 years ago

  • Assignee set to Michael Waack
Actions #6

Updated by Gerrit Code Review almost 5 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60573

Actions #7

Updated by Gerrit Code Review almost 5 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60573

Actions #8

Updated by Gerrit Code Review almost 5 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60573

Actions #9

Updated by Gerrit Code Review almost 5 years ago

Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/60581

Actions #10

Updated by Michael Waack almost 5 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #11

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF