diff --git a/src/Common/UiElement.php b/src/Common/UiElement.php index 849b2f8..a869fdc 100644 --- a/src/Common/UiElement.php +++ b/src/Common/UiElement.php @@ -214,7 +214,7 @@ class UiElement implements \ArrayAccess, \Iterator, \JsonSerializable { if ( $this->options['tag-type'] ?? false ) { if ( $this->options['tag-type'] === "single" ) { - return $opentag . $content; + $closetag = ""; } } elseif ( in_array('force-tag-close', $this->options) ) { diff --git a/src/Method/FormContext.php b/src/Method/FormContext.php index 4d1d22d..f4a0251 100644 --- a/src/Method/FormContext.php +++ b/src/Method/FormContext.php @@ -7,6 +7,8 @@ use Psr\Http\Message\ServerRequestInterface, class FormContext implements FormContextInterface { + public string $formName; + public bool $formSent; public array $values = []; @@ -17,9 +19,14 @@ class FormContext implements FormContextInterface public ? ResponseInterface $response = null; - public function __construct(ServerRequestInterface $request) + public function __construct(ServerRequestInterface $request, ? string $formName = null) { $this->request = $request; + + if ( $formName ) { + $this->formName = $formName; + } + $this->values = $request->getParsedBody() ?: []; } @@ -38,7 +45,7 @@ class FormContext implements FormContextInterface { return $this->formSent; } - + public function __set($key, $value) { return $this->set($key, $value); diff --git a/src/Method/FormHandler.php b/src/Method/FormHandler.php index ba3308c..64acb60 100644 --- a/src/Method/FormHandler.php +++ b/src/Method/FormHandler.php @@ -25,10 +25,19 @@ class FormHandler { else { $this->context = method_exists($form, 'getContext') ? $form->getContext($request) : new FormContext($request); } - - $this->context->formSent = $this->sent; + + $this->formSent(); $this->initialize(); } + + protected function formSent() : void + { + if ( false !== $this->context->formSent = $this->sent ) { + if ( $this->context->formName ?? false ) { + $this->context->formSent = (bool) ( $this->request->getParsedBody()['picea-ui-form'][$this->context->formName] ?? false ); + } + } + } protected function initialize() : void {