Search code examples
typo3extbasetypo3-12.x

TYPO3 - Pass arguments of searchForm to 2 Plugins


I'am migrating a an old flexform to multiple plugins in TYPO3 12.

Now it seems I have a simple problem but could not find a good solution.

I have 2 plugins:

  1. searchForm

  2. List

both are using the same Controller and have 2 different Actions:

  • searchFormAction
  • ListAction

Now I need to have a simple selectbox in the searchform and I need the arguments of the searchForm in both plugins and also in both actions not only in one.

It seems, that when I create an selectbox in searchform via

<f:form.select name="myproperty" options="{0: 'Please Select', 1: 'first option'}" value="{selectedValueFromController}"/>

it results in HTML

<select name="tx_myextension_searchform[myproperty]" ....>

so it puts "searchform" in the selectname.

I assume, this is why I can only get its post-values in controller-action "searchFormAction" and not in listAction. I do this via:

$arrRequest = $this->request->getArguments();

how can I get the values of searchform in both actions ?

Thanks for any hints or also workarounds. How can it be done in "best practice"


Solution

  • $this->request->getArguments() only returns values that are prefixed with the plugin name tx_myextension_searchform. But you can still access them via $_POST/$_GET globals.

    There are multiple valid solutions to your problem, but it depends on how your project works, if you can find a clean easy solution or have to rebuild your whole extension.