‪TYPO3CMS  ‪main
FormState.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 /*
19  * Inspired by and partially taken from the Neos.Form package (www.neos.io)
20  */
21 
23 
26 
36 {
41  public const ‪NOPAGE = -1;
42 
49 
53  protected ‪$formValues = [];
54 
58  public function ‪isFormSubmitted(): bool
59  {
60  return $this->lastDisplayedPageIndex !== ‪self::NOPAGE;
61  }
62 
63  public function ‪getLastDisplayedPageIndex(): int
64  {
66  }
67 
69  {
70  $this->lastDisplayedPageIndex = ‪$lastDisplayedPageIndex;
71  }
72 
73  public function ‪getFormValues(): array
74  {
75  return ‪$this->formValues;
76  }
77 
81  public function ‪setFormValue(string $propertyPath, $value)
82  {
83  $this->formValues = ‪ArrayUtility::setValueByPath(
84  $this->formValues,
85  $propertyPath,
86  $value,
87  '.'
88  );
89  }
90 
94  public function ‪getFormValue(string $propertyPath)
95  {
96  try {
97  return ‪ArrayUtility::getValueByPath($this->formValues, $propertyPath, '.');
98  } catch (MissingArrayPathException $exception) {
99  return null;
100  }
101  }
102 }
‪TYPO3\CMS\Form\Domain\Runtime\FormState\setFormValue
‪setFormValue(string $propertyPath, $value)
Definition: FormState.php:79
‪TYPO3\CMS\Form\Domain\Runtime\FormState\isFormSubmitted
‪bool isFormSubmitted()
Definition: FormState.php:56
‪TYPO3\CMS\Form\Domain\Runtime\FormState\NOPAGE
‪const NOPAGE
Definition: FormState.php:41
‪TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException
Definition: MissingArrayPathException.php:27
‪TYPO3\CMS\Form\Domain\Runtime\FormState\$formValues
‪array $formValues
Definition: FormState.php:51
‪TYPO3\CMS\Form\Domain\Runtime\FormState\getLastDisplayedPageIndex
‪getLastDisplayedPageIndex()
Definition: FormState.php:61
‪TYPO3\CMS\Form\Domain\Runtime\FormState
Definition: FormState.php:36
‪TYPO3\CMS\Form\Domain\Runtime\FormState\setLastDisplayedPageIndex
‪setLastDisplayedPageIndex(int $lastDisplayedPageIndex)
Definition: FormState.php:66
‪TYPO3\CMS\Form\Domain\Runtime\FormState\$lastDisplayedPageIndex
‪int $lastDisplayedPageIndex
Definition: FormState.php:47
‪TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath
‪static getValueByPath(array $array, array|string $path, string $delimiter='/')
Definition: ArrayUtility.php:176
‪TYPO3\CMS\Form\Domain\Runtime
‪TYPO3\CMS\Form\Domain\Runtime\FormState\getFormValue
‪mixed getFormValue(string $propertyPath)
Definition: FormState.php:92
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:26
‪TYPO3\CMS\Form\Domain\Runtime\FormState\getFormValues
‪getFormValues()
Definition: FormState.php:71
‪TYPO3\CMS\Core\Utility\ArrayUtility\setValueByPath
‪static array setValueByPath(array $array, string|array|\ArrayAccess $path, mixed $value, string $delimiter='/')
Definition: ArrayUtility.php:261