paulbrause Posted June 13, 2016 Posted June 13, 2016 Hi! I have a formular like this: <form action="/test/" method="post"> <input type="text" name="test[1234]['value1']" /> <input type="text" name="test[1234]['value2']" /> <input type="text" name="test[1234]['value3']" /> <input type="text" name="test[2345]['value1']" /> <input type="text" name="test[2345]['value2']" /> <input type="text" name="test[2345]['value3']" /> ... <input type="hidden" id="_post_token" name="{$this->session->CSRF->getTokenName()}" value="{$this->session->CSRF->getTokenValue()}"/> <input type="submit" value="Submit" name="submit" /> </form> For testing the processing of the form looks likes this: if($input->post->submit && $session->CSRF->validate()) { $data_pw = $input->post["test"]; $data_post = $_POST["test"]; echo "<pre>"; print_r($data_pw); print_r($data_post); echo "</pre>"; } But i always get something like this... Array ( ) Array ( [1234] => Array ( ["value1"] => "Test" ["value2"] => "Hi" ["value3"] => "Hello again" ) [2345] => Array ( ["value1"] => "Oh no" ["value2"] => "Wait, what?" ["value3"] => "Bye bye" ) ) Why is $input->post["test"] returned as an empty array? Am i doing something wrong? (using PW 3.0.18)
Soma Posted June 13, 2016 Posted June 13, 2016 PW doesn't allow for multidimensional post arrays. https://processwire.com/talk/topic/691-wireinput-only-allows-one-dimensional-arrays-why/ 1
paulbrause Posted June 13, 2016 Author Posted June 13, 2016 Thanks Soma! Will use $_POST["test"] instead...
NoremPload Posted June 1, 2017 Posted June 1, 2017 got a similar problem <form id="testform" class="col s12 InputfieldForm" name="testform" method="post" action="" data-colspacing="1"> <input placeholder="w / kW" id="power" name="power" type="text"> <input value="8,5" id="price" name="price" type="text"> . . </form> after sending the form i get following output with=> print_r($input->post); print_r($_POST); ProcessWire\WireInputData Object ( ) Array ( [power] => [days] => 3 [price] => 8,5 [power_form_sent] => 1 [submit] => submit ) tried to change action to full URL etc, did not help any ideas ?
Craig Posted June 1, 2017 Posted June 1, 2017 16 minutes ago, NoremPload said: print_r($input->post); You need to call this as a function to get all POST data: $input->post();
NoremPload Posted June 1, 2017 Posted June 1, 2017 Thx! OMG, found a typo somewhere else i checked for $input->post["power_form_sent"] and it was empty because of the typo
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now