Jump to content

Can't get POST data


MarkE
 Share

Recommended Posts

Sorry if I'm being a bit dim, but I'm struggling with a form submission. I have a form (InputfieldForm) with values, which are set programmatically, in hidden inputfields and a submit button. The action is an admin page with a custom process. Previously, I just had the button (no form) and a data-href with url parameters which the custom admin page picked up via $_GET - this worked fine. Then I wanted to add a load more parameters and decided to change to the post method. However, the POST parameters do not seem to be available to the custom page ($_POST is empty and $this->input->post->submit is null too). I can see from the developer tools that the POST has worked and that the parameters are there.

Any ideas what I might be doing wrong?

Link to comment
Share on other sites

22 minutes ago, MarkE said:

The action is an admin page with a custom process

You mean a module?

How do you post? The "traditional" way (form submit on click), or via AJAX?

These topics may be related to your issue:

https://processwire.com/talk/topic/19486-input-get-post-inside-of-process-module/

https://processwire.com/talk/topic/17168-input-post-empty-with-dynamically-added-input-fields/

 

 

Link to comment
Share on other sites

 

1 hour ago, dragan said:

You mean a module?

Yes

1 hour ago, dragan said:

How do you post? The "traditional" way (form submit on click), or via AJAX?

Submit on click. No AJAX here (ironically, elsewhere, I got AJAX posts working).

The action page is loaded fine on submit. The dev tools show the POST params are there. But the ___execute() function in the module sees nothing. (All in Superuser, BTW).

Link to comment
Share on other sites

If the post fields are present, maybe check the spelling of the fields in $input->post("var_name")? I know it sounds simple, but I sometimes misspell the field names and wonder why I don't get the values submitted. Maybe that's just me. ?

Link to comment
Share on other sites

2 hours ago, MarkE said:

$_POST is empty and $this->input->post->submit is null too

Well that is true, but $this->input->post['param'] is filled correctly! Sorry for the slight red herring. I obviously misunderstood in thinking I could use $_POST (as $_GET was OK) .

Link to comment
Share on other sites

As always, it's never simple. When I used the GET method, I linked to the action page via a data-href attribute in the InputfieldButton. It also had class="pw-modal". Now, with the POST method (working!), I have had to remove the data-href and have the action in the form element. That means I can no longer use pw-modal. So how do I get the action page in a modal?

Update: I gave up and went back to using GET. I could not find a way of getting POST and pw-modal to work together. 

Edited by MarkE
Update
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...