This is because you init dropdown with integer values, but after
submit they come as string from web.input.
Try: form.Dropdown("year", [str(i) for i in range(1900, today.year
+1)], vdate, value=str(today.year))
On Aug 4, 5:38 am, Troels Mæhl Folke <[email protected]>
wrote:
> Hello out there
> I have a field in a form which looks like this:
>
> form.Dropdown("year", range(1900, today.year+1), vdate, value=today.year)
>
> where vdate is a validator and today is a datetime.datetime object.
>
> When the form is rendered for the first time, value (the year 2011) is
> selected by default in the dropdown widget as it should.
> However, when the form is rendered for the second time after form data has
> been posted, been subject to validation and eventually been used in a
> database query, value is not the default option - the first option (the year
> 1900) is.
> Also, if the user selects an option, the choice is not preserved when the
> form is rendered again, as user input in textboxes is.
>
> Is there any way to make any of these things happen (preferably withouth
> touching javascript, and without violating DRY too much).
>
> Thanks in advance
> Troels
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.