After a couple of hours trying to figure out why my form processing wasn't working, I think I've found a bug in webhelpers, or possibly in prototype itself.
Here are links to the pastebin for the controller and template to show this bug: http://pylonshq.com/pasties/95 http://pylonshq.com/pasties/94 What's happening is that whatever javascript eats form variables and serializes them to be sent via XMLHTTPRequest has a parsing error. It seems that if there a value of "" (emptystring) in the value attribute of a <select> tag, it decides to grab onto the display/label string instead. SO: <select name="product"> <option value="">Choose One</option> <option value="1">A</option> <option value="2">B</option> <option value="3">C</option> </select> If the user submits without choosing an option, the submission will contain "Choose One" for the value. That's not a value! Shall I put in a bug ticket, or is this upstream? Thanks. (if you don't like the paste bin:) Here is the controller: ================================================= from spnwww.lib.base import * class BrokenpostController(BaseController): def index(self): return render_response('broken.html') def submit(self): vars = request.environ['paste.parsed_formvars'][0] return Response("<p>Raw values:</p>\n" + str(vars)) ================================================= Here is the template: ================================================= <html> <head> <title>bug</title> ${h.javascript_include_tag(builtins=True)} </head> <body> <div id="dump"></div> <% form_tag_str = h.form_remote_tag( url = h.url(controller='brokenpost', action='submit'), update = 'dump', ) %> form w/form_remote_tag ${form_tag_str} <select id="field_product" name="product"> <option value=""> (Not a Value!) </option> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> </select> <input name="save" type="submit" value="save" id="field_save" /> </form> <hr> form w/normal post <form action="/brokenpost/submit" method="post"> <select id="field_product" name="product"> <option value=""> (Not a Value!) </option> <option value="1">One</option> <option value="2">Two</option> <option value="3">Three</option> </select> <input name="save" type="submit" value="save" id="field_save" /> </form> </body> </html> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
