adrianmak Posted February 25, 2016 Share Posted February 25, 2016 I have a form with a checkboxes input field, look something like <input name="choices[1276][]" value="1280" type="checkbox"> <input name="choices[1276][]" value="1285" type="checkbox"> <input name="choices[1276][]" value="1292" type="checkbox"> If I use ordinary PHP fucntion $_POST['choices'], I could get this value. If I use pw's way $input->post['choices'], i got nothing I used sizeof to check sizeof($_POST['choices']) -> returned 1 is any of a checkbox is checked sizeof($input->post['choices']) -> returned 0 if a checkbox is checked. Link to comment Share on other sites More sharing options...
justb3a Posted February 25, 2016 Share Posted February 25, 2016 I can confirm this behaviour. Noticed this some months ago and had to use $_POST for any two dimensional input. Link to comment Share on other sites More sharing options...
cstevensjr Posted February 25, 2016 Share Posted February 25, 2016 Does anyone know if there has been an Github issue created for this? If so, can you please reference in this post? If not, can you open an issue? Link to comment Share on other sites More sharing options...
adrian Posted February 25, 2016 Share Posted February 25, 2016 A couple of relevant posts: https://processwire.com/talk/topic/691-wireinput-only-allows-one-dimensional-arrays-why/ https://processwire.com/talk/topic/7867-input-and-associative-array-issue/ From Ryan: The main reason it's not there is just because $input is another layer on top of $_POST (or $_GET or $_COOKIE) and I wanted to limit the overhead of it as much as possible, at least until we needed it. Didn't want to enable the possibility of someone posting endless multidimensional arrays from a security standpoint. But ultimately if the need was there, I would add it. And now that its come up, we might as well add it. Probably what I will do is just limit the recursion to 2 or 3 levels to keep it safe. I don't see any potential issues with adding it. If you've had the need for it, then I'm sure others will to. If you want to submit a pull request, I'll bring it into the core. Otherwise, I'll plan to add and commit an update to the core soon. 2 Link to comment Share on other sites More sharing options...
kongondo Posted February 25, 2016 Share Posted February 25, 2016 Yeah. Probably time to add this to the $input docs. Link to comment Share on other sites More sharing options...
tpr Posted February 25, 2016 Share Posted February 25, 2016 Is this happening to variables passed to wireRenderFile too? I experienced such an issue but haven't investigate further. Link to comment Share on other sites More sharing options...
LostKobrakai Posted February 25, 2016 Share Posted February 25, 2016 Afaik wireRenderFile does just do a "extract($vars)" to populate the local variables. There's no need to sanitize or otherwise limit data input. 1 Link to comment Share on other sites More sharing options...
tpr Posted February 25, 2016 Share Posted February 25, 2016 That shouldn't cause that, thanks. I'll re-check when it happens again but I guess there's something other that interferes. Link to comment Share on other sites More sharing options...
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