[BUGFIX] Provide addQueryStringMethod for ViewHelper f:form 89/50489/3
authorGeorg Ringer <georg.ringer@gmail.com>
Thu, 3 Nov 2016 07:33:51 +0000 (08:33 +0100)
committerMarkus Klein <markus.klein@typo3.org>
Sun, 13 Nov 2016 08:48:13 +0000 (09:48 +0100)
Make it possible to set the addQueryStringMethod for the f:form
ViewHelper. Otherwise it is impossible to add parameters resolved
by realurl. This has been fixed in master already.

Resolves: #78553
Releases: 7.6
Change-Id: I79a491ec20d8067d410cd8d74a732dc3a45f26d4
Reviewed-on: https://review.typo3.org/50489
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php

index 9176b3b..8cb6621 100644 (file)
@@ -144,9 +144,10 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH
      * @param string $actionUri can be used to overwrite the "action" attribute of the form tag
      * @param string $objectName name of the object that is bound to this form. If this argument is not specified, the name attribute of this form is used to determine the FormObjectName
      * @param string $hiddenFieldClassName
+     * @param string $addQueryStringMethod Method to use when keeping query parameters (GET or POST, only active if $actionUri is not set)
      * @return string rendered form
      */
-    public function render($action = null, array $arguments = [], $controller = null, $extensionName = null, $pluginName = null, $pageUid = null, $object = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '', array $additionalParams = [], $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], $fieldNamePrefix = null, $actionUri = null, $objectName = null, $hiddenFieldClassName = null)
+    public function render($action = null, array $arguments = [], $controller = null, $extensionName = null, $pluginName = null, $pageUid = null, $object = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '', array $additionalParams = [], $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], $fieldNamePrefix = null, $actionUri = null, $objectName = null, $hiddenFieldClassName = null, $addQueryStringMethod = '')
     {
         $this->setFormActionUri();
         if (strtolower($this->arguments['method']) === 'get') {
@@ -197,7 +198,26 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH
         } else {
             $uriBuilder = $this->controllerContext->getUriBuilder();
             $pageUid = (int)$this->arguments['pageUid'] > 0 ? (int)$this->arguments['pageUid'] : null;
-            $formActionUri = $uriBuilder->reset()->setTargetPageUid($pageUid)->setTargetPageType($this->arguments['pageType'])->setNoCache($this->arguments['noCache'])->setUseCacheHash(!$this->arguments['noCacheHash'])->setSection($this->arguments['section'])->setCreateAbsoluteUri($this->arguments['absolute'])->setArguments((array)$this->arguments['additionalParams'])->setAddQueryString($this->arguments['addQueryString'])->setArgumentsToBeExcludedFromQueryString((array)$this->arguments['argumentsToBeExcludedFromQueryString'])->setFormat($this->arguments['format'])->uriFor($this->arguments['action'], $this->arguments['arguments'], $this->arguments['controller'], $this->arguments['extensionName'], $this->arguments['pluginName']);
+            $formActionUri = $uriBuilder
+                ->reset()
+                ->setTargetPageUid($pageUid)
+                ->setTargetPageType($this->arguments['pageType'])
+                ->setNoCache($this->arguments['noCache'])
+                ->setUseCacheHash(!$this->arguments['noCacheHash'])
+                ->setSection($this->arguments['section'])
+                ->setCreateAbsoluteUri($this->arguments['absolute'])
+                ->setArguments((array)$this->arguments['additionalParams'])
+                ->setAddQueryString($this->arguments['addQueryString'])
+                ->setAddQueryStringMethod($this->arguments['addQueryStringMethod'])
+                ->setArgumentsToBeExcludedFromQueryString((array)$this->arguments['argumentsToBeExcludedFromQueryString'])
+                ->setFormat($this->arguments['format'])
+                ->uriFor(
+                    $this->arguments['action'],
+                    $this->arguments['arguments'],
+                    $this->arguments['controller'],
+                    $this->arguments['extensionName'],
+                    $this->arguments['pluginName']
+                );
             $this->formActionUriArguments = $uriBuilder->getArguments();
         }
         $this->tag->addAttribute('action', $formActionUri);