HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Adding array to hidden form data
hgtonight
MVP
I am having trouble passing data through to another form.
I have an array of UserIDs that I want to pass from one form into a different form. I had the bright idea of using Form->AddHidden() on the controller side, but I can't figure out how to pass it an array of data.
Current workflow:
- Inject form fields through a plugin hook Check
- Post form upon control change to a different controller via JS Check
- Process received data and add new array to form data ???
- Show form via standard Vanilla syntax Check
- Process data as usual Check but I can't access the array
- Profit!
Thoughts?
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
0
Comments
sorry can you explain better what it is you are trying to do?
Why are you passing a bunch of ids via form fields?
grep is your friend.
Did you initialize the array first? or is the data there, but you just don't know how to get to it?
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
You can use the form
name="FormPrefix/FieldName[]"
Try this
Or
grep is your friend.
On second thoughts you may have to do it like this
You could of course serialise.
grep is your friend.
Thanks for the replies
So far, none of this has worked.
I am writing a plugin that injects some checkboxes into existing dashboard fields. I am then submitting that form via JS so I can post the form data to a different controller. I have the controller set up and am able to recieve/process the data just fine.
If I just do the actions I want to, everything is hunky dory. I really need a confirm button before releasing this as a plugin. So I need to figure out how to pass the array of userids back into the different form.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
if you want to pm where to see code, I'd be glad to check it out later today.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
why don't you just serialise the array?
grep is your friend.
What are you doing with these ids?
grep is your friend.
I should have thought of this. I seem to be having some issues thinking outside the box.
Different things. Always editing some aspect of the list of users.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
Well, serialisation is quite thinking "inside" the box.
Personally, in this cases, I serialise using either
serialize()
or, better,json_encode()
. I tend to prefer the latter because I can use field content in JavaScript as well. Besides, it's more readable and easier to debug, in my opinion.My shop | About Me
I'm afraid that it won't work. Vanilla "sanitises" field names, and it escapes square brackets. When I developed my Badges plugin, I wanted to group fields in a hierarchical way and I had to develop an override mechanism to ensure that the square brackets were preserved.
My shop | About Me
Serializing worked, @x00. Thanks!
@businessdad Thinking inside the box might be the wrong term. More like "I have a hammer and dammit if this screw won't work as a nail!" I really like the idea of json_encoded data, since I will be expanding this in the future.
Search first
Check out the Documentation! We are always looking for new content and pull requests.
Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.
I use
In one of my plugins then I use javascript to extend.
It does escape when you place some value in the brackets, I experimented a bit.
grep is your friend.
library/core/class.form.php
grep is your friend.