Search code examples
pluginshttp-posttypo3typo3-7.6.xextension-builder3

Typo3 frontend plugin, use _POST data in the controller


I wrote a very simple extension in typo3 v7.6.11 with the extension builder where a visitor can ask for a taxi-ride.

everything works, only that I need to make the request more appealing by asking the pick-up point and the drop-off point ... that request goes to the actual form like this in the template (requestPid is the id of the page with the form):

<f:form pageUid="{settings.additional.requestPid}" action="form" name="request" object="{Request}">
  <f:render partial="Ticket/RequestNewFields" />
  <f:form.submit value="{f:translate(key: 'tx_wmnltickets_domain_model_ticket.admin.continue')}" />
</f:form>

but the formAction in the controler doesn't actually ask anything from the model (getArguments() I tried);

/**
 * action form
 * 
 * @return void
 */
public function formAction() {
    $this->request->getArguments();
}

the request does send the $_POST but I see no way to get it into the form ... if you'd like to see more code to understand, just ask, I don't know what you'd be looking for ...


Solution

  • Your form action should has the request parameter from you form:

    /**
     * action form
     * 
     * @param array $request
     *
     * @return void
     */
     public function formAction($request) {
     }
    

    Then you can access the data with $request['origin']

    I'm not sure if the variable $request is allowed as argument. Maybe you must rename it in the function and in your fluid template if it doesn't work.