[TYPO3-mvc] Problem with <f:form.submit> and <<f:form>

Franz Koch typo3.RemoveForMessage at elements-net.de
Tue Aug 3 18:03:14 CEST 2010


Hey folks,

> I have the same problems with Phong, There are many<f:form.submit>  in a
> form and I want many action for buttons
> My mean: Click on Save button, then createAction in Controller will be
> called
> Click on Next Step, then nextStepAction in the Controller will be called
> Now, Both of buttons alway createAction in Controller
>
> Could you help me with problems, many thanks!!!

I think your form should trigger some "proxy" action and this "proxy" 
action is then checking which button was clicked and forward the request 
to the according action.


<f:form action="yourProxyAction">
....
	<f:form.submit name="do[actionName]" value="Your button Label" />
	<f:form.submit name="do[otherActionName]" value="Your other button" />
</f:form>


class Tx_YourExt_Domain_Controller_FooController {

   function yourProxyAction(whatever) {
     $action = 'default';
     $allowedActions = array('action1','action2','action3');

     if ($this->request->hasArgument('do')) {
	$requestedActions = $this->request->getArgument('do');
         foreach ($requestedActions as $actionName => $value) {
           if (!empty($value) && in_array($actionName, $allowedActions)) {
             $action = $actionName;
           }
        }
     }
     $this->forward($action,...);
   }
}



Something like that maybe. I think you might even be able to skip the 
foreach loop as there ideally should only be one item set in the 
argument - but that might depend on the browser and needs testing though.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list