diff --git a/src/Method/FormContext.php b/src/Method/FormContext.php index 676f16c..fe10aad 100644 --- a/src/Method/FormContext.php +++ b/src/Method/FormContext.php @@ -25,16 +25,24 @@ class FormContext implements FormContextInterface public ? ResponseInterface $response = null; - public function __construct(ServerRequestInterface $request, ? string $formName = null) + public function __construct(ServerRequestInterface $request, ? string $formName = null) { $this->request = $request; - + if ( $formName ) { - $this->formName = $formName; + $this->formName = $formName; } - + $this->values = $request->getParsedBody() ?: []; + if ( ! $this->values ) { + $content = utf8_encode((string) $request->getBody()); + + if ( $content && ( $json = json_decode($content, true) ) ) { + $this->values = $json; + } + } + $this->files = $request->getUploadedFiles() ?: []; }