‪TYPO3CMS  ‪main
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 
17 
24 
30 {
42  public function ‪afterSubmit(‪FormRuntime $formRuntime, ‪RenderableInterface $renderable, $elementValue, array $requestArguments = [])
43  {
44  if ($renderable->‪getType() === 'AdvancedPassword') {
45  if ($elementValue['password'] !== $elementValue['confirmation']) {
46  $processingRule = $renderable->getRootForm()->getProcessingRule($renderable->‪getIdentifier());
47  $processingRule->getProcessingMessages()->addError(
48  GeneralUtility::makeInstance(
49  Error::class,
50  GeneralUtility::makeInstance(TranslationService::class)->translate('validation.error.1556283177', null, 'EXT:form/Resources/Private/Language/locallang.xlf'),
51  1556283177
52  )
53  );
54  }
55  $elementValue = $elementValue['password'];
56  }
57 
58  return $elementValue;
59  }
60 
65  public function ‪beforeRendering(‪FormRuntime $formRuntime, ‪RootRenderableInterface $renderable)
66  {
67  if ($renderable->‪getType() === 'Date') {
68  $date = $formRuntime[$renderable->‪getIdentifier()];
69  if ($date instanceof \DateTime) {
70  // @see https://www.w3.org/TR/2011/WD-html-markup-20110405/input.date.html#input.date.attrs.value
71  // 'Y-m-d' = https://tools.ietf.org/html/rfc3339#section-5.6 -> full-date
72  $formRuntime[$renderable->‪getIdentifier()] = $date->format('Y-m-d');
73  }
74  }
75  }
76 }
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormRuntime.php:106
‪TYPO3\CMS\Form\Service\TranslationService
Definition: TranslationService.php:45
‪TYPO3\CMS\Form\Hooks\FormElementHooks
Definition: FormElementHooks.php:30
‪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:42
‪TYPO3\CMS\Form\Hooks
Definition: FormElementHooks.php:16
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface
Definition: RootRenderableInterface.php:31
‪TYPO3\CMS\Extbase\Validation\Error
Definition: Error.php:22
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface\getType
‪getType()
‪TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface\getIdentifier
‪getIdentifier()
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormSession.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Form\Hooks\FormElementHooks\beforeRendering
‪beforeRendering(FormRuntime $formRuntime, RootRenderableInterface $renderable)
Definition: FormElementHooks.php:65