I thought I remembered this question coming up before, but a quick look
didn't turn up what I want.
I have a straight-forward controller function for entering the primary data:
def index():
"""
"""
response.flash = T("Hello World")
form = SQLFORM(db.QuarterMaster)
form.vars.PostDate = str(request.now.year) + "-" + str(request.now.month
) + "-" + str(request.now.day)
if form.process().accepted:
form.vars.PostDate = request.vars.PostDate
response.flash = T("Thank you!")
elif form.errors:
response.flash = T("Please correct the errors in the form")
else:
response.flash = T("Please fill out the form")
return dict(form=form)
The intial display of the form shows the current date correctly (give or
take a leading 0), but after submission the PostDate field is empty. I
would like to have it default to what was used the previous time through,
but it appears that value is dropped after the accepted branch. What do I
need to do?
Maybe replace the top part with?
form = SQLFORM(db.QuarterMaster)
if request.vars.PostDate:
form.vars.PostDate = request.vars.PostDate
else:
form.vars.PostDate = str(request.now.year) + "-" + str(request.now.
month) + "-" + str(request.now.day)
if form.process().accepted:
# here was form.vars.PostDate = request.vars.PostDate
Thanks.
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.