diff --git a/src/Form/UiForm.php b/src/Form/UiForm.php index 24927f2..c9c7f8b 100644 --- a/src/Form/UiForm.php +++ b/src/Form/UiForm.php @@ -85,7 +85,7 @@ class UiForm extends UiElement implements Extension { if ($this->csrf) { $token = md5($name . microtime()); - $key = "picea-ui:form:{$name}"; + $key = "picea-ui.form:{$name}"; if (count($_SESSION[$key] ?? []) > 100) { array_shift($_SESSION[$key]); diff --git a/src/Method/FormContext.php b/src/Method/FormContext.php index 763ae43..f5bc8be 100644 --- a/src/Method/FormContext.php +++ b/src/Method/FormContext.php @@ -31,13 +31,8 @@ class FormContext implements FormContextInterface public function __construct( public ServerRequestInterface $formContextRequest, - ? string $formName = null - ) - { - if ( $formName ) { - $this->formName = $formName; - } - + public readonly ? string $formName = null + ) { $this->formContextValues = $formContextRequest->getParsedBody() ?: []; if ( ! $this->formContextValues ) { @@ -77,11 +72,11 @@ class FormContext implements FormContextInterface { $valid = in_array($this->requestMethod(), $this->formContextCatchedMethods); - if ( ! $this->formSkipCsrf && ($this->formName ?? false) ) { + if ( (! $this->formSkipCsrf) && ! empty($this->formName) ) { $token = $this->get('picea-ui-form')[$this->formName] ?? false; if ( $token ) { - if ($this->validateCsrfToken) { + if (! $this->formSkipCsrf) { $valid = in_array($token, $_SESSION["picea-ui.form:{$this->formName}"] ?? []); } else { @@ -211,7 +206,7 @@ class FormContext implements FormContextInterface } elseif ($types instanceof \ReflectionIntersectionType || $types instanceof \ReflectionUnionType) { foreach($types->getTypes() as $type) { - return $value = $cast($type->getName()); + return $cast($type->getName()); } }