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 41b1244
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Classes/ViewHelpers/FormViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* source code.
*/

use Neos\Flow\Annotations as Flow;
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 +23,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 +67,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 41b1244

Please sign in to comment.