‪TYPO3CMS  10.4
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 
25 
31 {
32 
46  public function ‪afterSubmit(‪FormRuntime $formRuntime, ‪RenderableInterface $renderable, $elementValue, array $requestArguments = [])
47  {
48  if ($renderable->‪getType() === 'AdvancedPassword') {
49  if ($elementValue['password'] !== $elementValue['confirmation']) {
50  $processingRule = $renderable->getRootForm()->getProcessingRule($renderable->‪getIdentifier());
51  $processingRule->getProcessingMessages()->addError(
52  GeneralUtility::makeInstance(ObjectManager::class)
53  ->get(
54  Error::class,
55  ‪TranslationService::getInstance()->translate('validation.error.1556283177', null, 'EXT:form/Resources/Private/Language/locallang.xlf'),
56  1556283177
57  )
58  );
59  }
60  $elementValue = $elementValue['password'];
61  }
62 
63  return $elementValue;
64  }
65 
73  public function ‪beforeRendering(‪FormRuntime $formRuntime, ‪RootRenderableInterface $renderable)
74  {
75  if ($renderable->‪getType() === 'Date') {
76  $date = $formRuntime[$renderable->‪getIdentifier()];
77  if ($date instanceof \DateTime) {
78  // @see https://www.w3.org/TR/2011/WD-html-markup-20110405/input.date.html#input.date.attrs.value
79  // 'Y-m-d' = https://tools.ietf.org/html/rfc3339#section-5.6 -> full-date
80  $formRuntime[$renderable->‪getIdentifier()] = $date->format('Y-m-d');
81  }
82  }
83  }
84 }
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormRuntime.php:103
‪TYPO3\CMS\Form\Service\TranslationService\getInstance
‪static TranslationService getInstance()
Definition: TranslationService.php:83
‪TYPO3\CMS\Form\Service\TranslationService
Definition: TranslationService.php:44
‪TYPO3\CMS\Form\Hooks\FormElementHooks
Definition: FormElementHooks.php:31
‪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:46
‪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:46
‪TYPO3\CMS\Form\Hooks\FormElementHooks\beforeRendering
‪beforeRendering(FormRuntime $formRuntime, RootRenderableInterface $renderable)
Definition: FormElementHooks.php:73
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28