Passing information for viewer to controller

Hi,

I cannot pass a $_POST variable from a viewer to a method in the desired controller. This happens in an Extension Builder plugin I built. I am using Typo3 11. Most online resources suggest that just defining the variable as exemplified below will work (provided the name of the $variable is the same as the name of the input in the form.

public function processFormAction($myValue = '')

I also tried using getArguments within the action defined above, as below

$myValue = $this->request->getArguments()['myValue'] ?? '';

This is how I defined the form:

<form action="{f:uri.action(action: 'search', controller: 'Books')}" method="post">

I am trying to avoid manually handling the $_POST[“myValue”] variable in the method; it is not the best practice, and I would benefit from Typo3’s sanitisation instead. Plus, I want to learn how to do this properly. I know the POST variable is accessible from the action within the controller. I can var_dump it. However, if I var_dump $myValue, I get nothing.

  • Is there any additional mapping or anything one must do to get the method to recognise the post variable?
  • Are there any very basic examples I can consume?

Thank you.

Problem solved.

Viewer:

    <f:form action='filter' object="Services" objectName="services">
        <f:form.submit value="Search" class="btn btn-primary"  />
        <f:form.textfield property="keyword" class="form-control" id="keyword" />
    </f:form>

Controller:

    public function filterAction(): \Psr\Http\Message\ResponseInterface
    {
        $keyword = $this->request->getArguments()["services"]["keyword"];
        // More logic goes here.
        return $this->htmlResponse();
    }