[FEATURE] Add argument addQueryStringMethod to f:form 42/49642/5
authorClaus Due <claus@namelesscoder.net>
Tue, 30 Aug 2016 09:33:03 +0000 (11:33 +0200)
committerJan Helke <typo3@helke.de>
Sun, 9 Oct 2016 11:44:21 +0000 (13:44 +0200)
The argument is passed to UriBuilder as-is and allows controlling
how the preserving of GET/POST arguments happens in f:form's
action URI generating method.

Change-Id: Ie2270c7f7205d4cff1736b02ca7d42c788213850
Resolves: #75139
Releases: master
Reviewed-on: https://review.typo3.org/49642
Reviewed-by: MichaƂ Jankiewicz <michal.jankiewicz@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Daniel Windloff <daniel.jc.windloff@googlemail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php

index 38992b2..6c905a0 100644 (file)
@@ -122,6 +122,7 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH
         $this->registerArgument('absolute', 'bool', 'If set, an absolute action URI is rendered (only active if $actionUri is not set)', false, false);
         $this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the action URI (only active if $actionUri is not set)', false, false);
         $this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the action URI. Only active if $addQueryString = TRUE and $actionUri is not set', false, []);
+        $this->registerArgument('addQueryStringMethod', 'string', 'Method to use when keeping query parameters (GET or POST, only active if $actionUri is not set', false, 'GET');
         $this->registerArgument('fieldNamePrefix', 'string', 'Prefix that will be added to all field names within this form. If not set the prefix will be tx_yourExtension_plugin');
         $this->registerArgument('actionUri', 'string', 'can be used to overwrite the "action" attribute of the form tag');
         $this->registerArgument('objectName', 'string', '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');
@@ -188,7 +189,26 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH
         } else {
             $pageUid = (int)$this->arguments['pageUid'] > 0 ? (int)$this->arguments['pageUid'] : null;
             $uriBuilder = $this->renderingContext->getControllerContext()->getUriBuilder();
-            $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);