So this is a long one…I’m working in Wordpress and mainly when it comes to forms I’ll just go with a plugin (form processing is not my strong suit), but currently I’m putting together a custom form for a client and need some expert advice.
Just to give you a quick rundown of what the form is and what I’d like it to do:
- It’s a rental quote form.
- The customer should be able to select different furniture pieces and input desired quantities.
- When the form is submitted, the most important data (besides the customer’s contact info) is the item’s name, that item’s ID number (which is supplied as meta data from that item’s post in WP), and the quantity of that specific item.
Now the trickiest part I’ve come across is trying to group the data for the item name, id, and quantity. And secondly, trying to render it nicely in the email that gets sent to the client. Here’s what I’ve got so far:
I know that must look incredibly slapdash. I’m basically learning form processing as I go. This is very much a prototype as you can see by the commented out parts I wanted to keep around for reference. Those will be removed in the final code.
Right now I’m passing the ID numbers as a hidden input, which isn’t great because all the id inputs are getting included in the final rendering. I know that’s the nature of a hidden input, but I couldn’t come up with a better solution. Any suggestions there?
Is there a better way to group these values (checkbox, text input, and supplied value) together and render them? I feel like my loop could be way better. Or maybe there’s a better way to include more data values into the inputs themselves?
This is all working by the way, I’m able to submit the form and get an email:
But as you can see the formatting is not great at all. As mentioned before I’m getting all the hidden values (for example that “ID number: 35” is from a non-selected item), and I’m also unable to add the text “Quantity” in front of it’s corresponding value without completely breaking the loop. So right now it’s just the number that was entered in the form.
Any help and/or advice would be greatly appreciated! If you need any more info just let me know.
Btw I have posted this to stackoverflow almost a week ago and I haven’t gotten any hits yet. I’m hoping maybe someone here could steer me in the right direction