[TYPO3-mvc] Multiple parameters for one action!?

Marc Bastian Heinrichs typo3 at mbh-web.de
Wed May 5 10:24:44 CEST 2010


Hi Roberto,

> One of my actions looks like this:
>
>      /**
>       * Action redirecting to destintaion
>       *
>       * @param Tx_MyExt_Domain_Model_Destination $destination The target
> destination
>       * @param string $keyword The keyword entered by the user
>       * @return void
>       */
>      protected function showAction(Tx_MyExt_Domain_Model_Destination
> $destination, $keyword)
>      {
>          // Do something
>      }
>
> My URL to call this action looks like this:
>
> http://blabla.com/?tx_myext_pi1[destination]=2&tx_myext_pi1[keyword]=bananarama&tx_myext_pi1[action]=show&tx_myext_pi1[controller]=MyController
>
> Extbase throws the following Exception at me:
> *#1253175643: The argument type for parameter "keyword" could not be
> detected.*
>
> Once, I switch the order of the destination and keyword parameters, I get
> the same exception but for the destination. If I remove one of the two
> parameters, it works. So my assumption would be, that Extbase can only cope
> with one and only one parameter in action methods!? And no, I do not use any
> PHP accelerators or other fancy stuff.

The GET/POST vars to action parameter mapping works only for objects or 
arrays and not for strings.
To get an string argument you have to fetch it by your own from the 
request object in your action method:
$keyword = '';
if ($this->request->hasArgument('keyword')) {
	$keyword = $this->request->getArgument('keyword');
}

Regards,
Marc Bastian


More information about the TYPO3-project-typo3v4mvc mailing list