How can I access POST params send from a view in the controller?

Hello,

i am currently developing a module for icingaweb2. I am submitting a select in a partial view via onchange=“this.form.submit()”. The action of the form refers to the same site the view is on, meaning the controller should be able to get the POST params. I then try to see the POST params in my controller via var_dump($_POST); But this always returns an empty array. What am i missing here? Any help is appreciated.

Greetings,
Michel W.

Have a look here for an example : https://github.com/patrickpr/trapdirector/blob/master/application/controllers/StatusController.php#L65

Don’t do this. There’s a better alternative:

<select class="autosubmit">
    ...
</select>

Then, Icinga Web 2 automatically submits the form once the user interacts with the drop-down. On the server-side you may even distinguish between a proper submit (manual button push) or such an autosubmit.

Though, to get the most out of it, make sure to use Icinga\Web\Form to build and process your form.

1 Like