Bug #87722

Forms: Error message of Advanced password is not translatable

Added by Daniel Koether 3 months ago. Updated 20 days ago.

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

100%

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

Associated revisions

Revision 9b975a13 (diff)
Added by Michael Waack about 1 month ago

[BUGFIX] Make AdvancedPassword confirmation error translatable

Resolves: #87722
Releases: master, 9.5
Change-Id: Icabb810a67a900ff0632256d36fb05b888912f83
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60573
Reviewed-by: Mathias Brodala <>
Reviewed-by: Björn Jacob <>
Reviewed-by: Susanne Moog <>
Reviewed-by: Ralf Zimmermann <>
Tested-by: TYPO3com <>
Tested-by: Ralf Zimmermann <>

Revision 591d8e99 (diff)
Added by Michael Waack about 1 month ago

[BUGFIX] Make AdvancedPassword confirmation error translatable

Resolves: #87722
Releases: master, 9.5
Change-Id: Icabb810a67a900ff0632256d36fb05b888912f83
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60581
Tested-by: TYPO3com <>
Tested-by: Ralf Zimmermann <>
Reviewed-by: Ralf Zimmermann <>

History

#1 Updated by Susanne Moog 3 months ago

  • Category set to Form Framework

#2 Updated by Bjoern Jacob about 2 months ago

  • Sprint Focus set to Remote Sprint

#3 Updated by Petra Neumann about 1 month ago

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

#4 Updated by Petra Neumann about 1 month ago

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

#5 Updated by Michael Waack about 1 month ago

  • Assignee set to Michael Waack

#6 Updated by Gerrit Code Review about 1 month 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

#7 Updated by Gerrit Code Review about 1 month 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

#8 Updated by Gerrit Code Review about 1 month 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

#9 Updated by Gerrit Code Review about 1 month 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

#10 Updated by Michael Waack about 1 month ago

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

#11 Updated by Benni Mack 20 days ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF