FlorianA Posted January 6, 2021 Posted January 6, 2021 Hi all, could it be that input()->post does not cope with multi-dimensional arrays from POST data? Example data (pasted from Firefox network analysis): { "add[91896][]": [ "30227", "30312" ], "add[89364][]": "30430", "nr[91896][30227]": "a", "nr[91896][30312]": "b", "nr[89364][30430]": "c", "nr[91896][30332]": "", ... } My code: print "===add=== "; print_r($_POST['add']); print "===nr=== "; print_r($_POST['nr']); print "===add=== "; print_r(input()->post('add')); print "===nr=== "; print_r(input()->post('nr')); Result: ===add=== Array ( [91896] => Array ( [0] => 30227 [1] => 30312 ) [89364] => Array ( [0] => 30430 ) ) ===nr=== Array ( [91896] => Array ( [30227] => a [30312] => b [30332] => [30389] => [30364] => [30432] => [30208] => [30403] => ) [89364] => Array ( [30430] => c [30332] => [30350] => [30389] => [30384] => [30432] => [30403] => ) ) ===add=== Array ( ) ===nr=== Array ( ) Any ideas what could be wrong?
Craig Posted January 6, 2021 Posted January 6, 2021 Unfortunately, PW only supports one dimension for arrays when using the API to process data. There's been some discussion on this topic at GitHub: https://github.com/processwire/processwire-issues/issues/387 4
FlorianA Posted January 7, 2021 Author Posted January 7, 2021 OK, thanks for the link. So I'll use the $_POST variable.
Jan Romero Posted September 12, 2024 Posted September 12, 2024 This was solved a couple of months after the OP by this PR: https://github.com/processwire/processwire/pull/161. See also the announcement blog post: https://processwire.com/blog/posts/pw-3.0.178/ Must be enabled in config.php: $config->wireInputArrayDepth = 2; 1
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