[TYPO3-dev] Parameter in Action does not work for every action
Xavier Perseguers
xavier at typo3.org
Sat Aug 16 17:11:34 CEST 2014
Hi Dirk,
> in my ForumController I have two actions:
>
> /**
> * action list
> *
> * @param \DH\Forum\Domain\Model\Forum $forum
> *
> * @return void
> */
> public function listAction(\DH\Forum\Domain\Model\Forum $forum) {...}
sounds strange to pass an argument of type "Forum" to an action supposed
to lists forums... but that's not the problem.
> /**
> * action show
> *
> * @param \DH\Forum\Domain\Model\Forum $forum
> * @return void
> */
> public function showAction(\DH\Forum\Domain\Model\Forum $forum) {...}
>
> in my Forum\list.html I entered
> <f:link.action controller="Forum" action="show" arguments="{forum :
> forum}">{forum.title}</f:link.action>
>
> (the action used is show or list).
>
> When I click the link with the action "show" the param is set in the
> showAction method as expected. When I click the link with action "list"
> I get the exception
You did not post the link you defined with action "list". If it exactly
the same as "show", it must work.
> Oops, an error occurred!
>
> PHP Catchable Fatal Error: Argument 1 passed to
> DH\Forum\Controller\ForumController::listAction() must be an instance of
> DH\Forum\Domain\Model\Forum, none given in
> /media/sf_Virtual_Box_Shared_Folder/t3_forum/forum/Classes/Controller/ForumController.php
> line 57
Looks like your link is of the form
<f:link.action controller="Forum" action="list">whatever</f:link.action>
> Any idea, why this happens or does not work? Is there also a possibility
> to do cross controller parameter injection? This means in my
> Category\list.html I would like to set a f:link with arguments {category
> : category} and the controller Forum and the action list.
of course.
> If now someone clicks a category, I want to show the categories forums.
>
> Is this possible or do I have to use the Category controller with action
> show and do a redirect to the Forum\list view?
No, just provide the info you need using attribute "arguments".
Kind regards
--
Xavier Perseguers
TYPO3 CMS Team Member
TYPO3 .... inspiring people to share!
Get involved: http://typo3.org
More information about the TYPO3-dev
mailing list