Handling empty select option tag in Twill submit?

29 views
Skip to first unread message

PeterB

unread,
Sep 29, 2011, 5:17:25 PM9/29/11
to twill-dev
Hi all,

I have a simple case of something like this on a page I'm testing with
Twill

<form...>
...
<select name="aSelect" id="aSelect">
<option value=""></option>
<option value="33">a value</option>
<option value="54">another value</option>
...

If I call the submit method, aSelect will be given a GET/POST value of
"33" by default however, since the first entry listed is actually
empty, I don't want anything sent unless I actually set it myself.

Showform for this control confirms that the first line is skipped:
...
9 aSelect select aSelect ['33'] of ['33', '54',
'51', '18', ' ...
...

Looking through the debugger, HTML parser doesn't seem to even provide
it to _mechanize if there's no content in the tag.

As a workaround, I thought to explicitly try to set the value of
aSelect to empty string or None with set_form_control_value but this
throws the ClientForm.AmbiguityError (multiple matches to value/label
"" in list control) to since there is no value for this "empty" entry
in the control.
Browsers seem to be able to skip setting the control on submit
requests if there is no value but I'm stumped how to get the same
behaviour in Twill when I can't modify the underlying HTML to include
anything in the body of the option tag.
Anything else I can try?
PeterB
Reply all
Reply to author
Forward
0 new messages