Skip to content

Commit

Permalink
BUGFIX: configured base uri in form action uri
Browse files Browse the repository at this point in the history
  • Loading branch information
simstern committed Feb 9, 2022
1 parent b40e709 commit 8ac6011
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Classes/ViewHelpers/FormViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* source code.
*/

use Neos\Flow\Http\BaseUriProvider;
use Neos\Flow\Mvc\ActionRequest;
use Neos\FluidAdaptor\ViewHelpers\FormViewHelper as FluidFormViewHelper;
use Neos\Form\Core\Runtime\FormRuntime;
Expand All @@ -21,6 +22,13 @@
*/
class FormViewHelper extends FluidFormViewHelper
{

/**
* @Flow\Inject
* @var BaseUriProvider
*/
protected $baseUriProvider;

/**
* Renders hidden form fields for referrer information about
* the current request.
Expand Down Expand Up @@ -58,10 +66,15 @@ protected function getFormObjectName()
protected function getFormActionUri()
{
/** @var ActionRequest $actionRequest */
$actionRequest = $this->controllerContext->getRequest();
$uri = $actionRequest->getHttpRequest()->getUri();
if ($this->hasArgument('section') && $this->arguments['section'] !== '') {
$uri = $uri->withFragment($this->arguments['section']);
$actionRequest = clone $this->controllerContext->getRequest();
$requestUri = $actionRequest->getHttpRequest()->getUri();
$uri = $this->baseUriProvider->getConfiguredBaseUriOrFallbackToCurrentRequest()
->withPath($requestUri->getPath())
->withQuery($requestUri->getQuery())
->withFragment($requestUri->getFragment());

if ($this->hasArgument('section')) {
$uri = preg_replace('/#.*$/', '', $uri) . '#' . $this->arguments['section'];
}
return (string)$uri;
}
Expand Down

0 comments on commit 8ac6011

Please sign in to comment.