--- /dev/null
+.. include:: ../../Includes.txt
+
+===============================================================
+Deprecation: #84449 - TranslateElementErrorViewHelper arguments
+===============================================================
+
+See :issue:`84449`
+
+Description
+===========
+
+The template EXT:form/Resources/Private/Frontend/Partials/Field/Field.html has been changed. This
+was necessary because of a bug with validation messages containing arguments.
+For compatibility reasons, the old template syntax is still supported but is deprecated and will be
+removed with TYPO3 v10.
+
+Impact
+======
+
+If a user utilizes his own template for EXT:form/Resources/Private/Frontend/Partials/Field/Field.html,
+a deprecation warning will be thrown.
+
+
+Affected Installations
+======================
+
+Any installation which uses the form framework and a customized template for
+EXT:form/Resources/Private/Frontend/Partials/Field/Field.html.
+
+
+Migration
+=========
+
+Change
+
+.. code-block:: html
+
+ {formvh:translateElementError(element: element, code: error.code, arguments: error.arguments, defaultValue: error.message)}
+
+to
+
+.. code-block:: html
+
+ {formvh:translateElementError(element: element, error: error)}
+
+
+.. index:: Frontend, ext:form
\ No newline at end of file
* The TYPO3 project - inspiring people to share!
*/
+use TYPO3\CMS\Extbase\Validation\Error;
use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
use TYPO3\CMS\Form\Service\TranslationService;
public function initializeArguments()
{
$this->registerArgument('element', RootRenderableInterface::class, 'Form Element to translate', true);
- $this->registerArgument('code', 'integer', 'Error code', true);
- $this->registerArgument('arguments', 'array', 'Error arguments', false, null);
- $this->registerArgument('defaultValue', 'string', 'The default value', false, '');
+ $this->registerArgument('error', Error::class, '', false, '');
+ $this->registerArgument('code', 'integer', 'Error code - deprecated', false, '');
+ $this->registerArgument('arguments', 'array', 'Error arguments - deprecated', false, null);
+ $this->registerArgument('defaultValue', 'string', 'The default value - deprecated', false, '');
}
/**
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$element = $arguments['element'];
+ $error = $arguments['error'];
+
+ $code = $arguments['code'];
+ $errorArguments = $arguments['arguments'];
+ $defaultValue = $arguments['defaultValue'];
+
+ if ($error instanceof Error) {
+ $code = $error->getCode();
+ $errorArguments = $error->getArguments();
+ $defaultValue = $error->__toString();
+ } else {
+ trigger_error(
+ 'TranslateElementErrorViewHelper arguments "code", "arguments" and "defaultValue" has been deprecated in v8 and will be removed in v10. Use "error" instead.',
+ E_USER_DEPRECATED
+ );
+ }
/** @var FormRuntime $formRuntime */
$formRuntime = $renderingContext
return TranslationService::getInstance()->translateFormElementError(
$element,
- $arguments['code'],
- $arguments['arguments'],
- $arguments['defaultValue'],
+ $code,
+ $errorArguments,
+ $defaultValue,
$formRuntime
);
}