list at joreybump.com
Tue Mar 28 10:43:30 EST 2006
Peter Sheldrick wrote: > How must i tweak my python code so that mod_publisher successfully > understands radio buttons? atm i have two radio buttons that have the > same name="" attribute - but mod_publisher automatically maps name > attributes to python variables; if there are two input forms with the > same name it gets confused. But this is compulsory for radio buttons. Is > there an easy way out? You'll have to provide an example of the problem. When a form is submitted, req.form will contain only one value for a radio button, if one of the options was selected. Publisher doesn't know what a radio button is, but form values are mapped to keys in req.form. If multiple values are submitted, the result will be a list, not a string, so you'll need to check the type of the value that corresponds to any given key. This wouldn't happen with a radio button group, though, because there will only be one choice, unless the name is used elsewhere (a hidden input or in the URL). FWIW, I don't use the automatic mapping offered by publisher at all. I find that using req.form is more flexible and reliable (you don't have to worry about namespace collisions when you're using keys).