‪TYPO3CMS  11.5
FormElementHooks.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
16 namespace ‪TYPO3\CMS\Form\Hooks;
17 
24 
30 {
44  public function ‪afterSubmit(‪FormRuntime $formRuntime, ‪RenderableInterface $renderable, $elementValue, array $requestArguments = [])
45  {
46  if ($renderable->‪getType() === 'AdvancedPassword') {
47  if ($elementValue['password'] !== $elementValue['confirmation']) {
48  $processingRule = $renderable->getRootForm()->getProcessingRule($renderable->‪getIdentifier());
49  $processingRule->getProcessingMessages()->addError(
50  GeneralUtility::makeInstance(
51  Error::class,
52  GeneralUtility::makeInstance(TranslationService::class)->translate('validation.error.1556283177', null, 'EXT:form/Resources/Private/Language/locallang.xlf'),
53  1556283177
54  )
55  );
56  }
57  $elementValue = $elementValue['password'];
58  }
59 
60  return $elementValue;
61  }
62 
70  public function ‪beforeRendering(‪FormRuntime $formRuntime, ‪RootRenderableInterface $renderable)
71  {
72  if ($renderable->‪getType() === 'Date') {
73  $date = $formRuntime[$renderable->‪getIdentifier()];
74  if ($date instanceof \DateTime) {
75  // @see https://www.w3.org/TR/2011/WD-html-markup-20110405/input.date.html#input.date.attrs.value
76  // 'Y-m-d' = https://tools.ietf.org/html/rfc3339#section-5.6 -> full-date
77  $formRuntime[$renderable->‪getIdentifier()] = $date->format('Y-m-d');
78  }
79  }
80  }
81 }
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormRuntime.php:109
‪TYPO3\CMS\Form\Service\TranslationService
Definition: TranslationService.php:45
‪TYPO3\CMS\Form\Hooks\FormElementHooks
Definition: FormElementHooks.php:30
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface\getIdentifier
‪string getIdentifier()
‪TYPO3\CMS\Form\Domain\Model\Renderable\RenderableInterface
Definition: RenderableInterface.php:32
‪TYPO3\CMS\Form\Hooks\FormElementHooks\afterSubmit
‪mixed afterSubmit(FormRuntime $formRuntime, RenderableInterface $renderable, $elementValue, array $requestArguments=[])
Definition: FormElementHooks.php:44
‪TYPO3\CMS\Form\Hooks
Definition: DataStructureIdentifierHook.php:18
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface
Definition: RootRenderableInterface.php:31
‪TYPO3\CMS\Extbase\Validation\Error
Definition: Error.php:22
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormSession.php:18
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface\getType
‪string getType()
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Form\Hooks\FormElementHooks\beforeRendering
‪beforeRendering(FormRuntime $formRuntime, RootRenderableInterface $renderable)
Definition: FormElementHooks.php:70