web2py - date picker issue

66 views
Skip to first unread message

Anuj Mahawar

unread,
May 5, 2020, 12:44:31 AM5/5/20
to web2py-users

I am a beginner to the web2py. I am building an application with a date picker on the home page. The issue is - Whenever I try to edit a previous day's record and submit, instead of on being on the same date, it is being redirected to the current date page. e.g. suppose I have logged in and it displays the current date i.e. 29 April 2020. When I try to edit a record for 01 April 2020 and submit the entry, it is being redirected to the current date i.e. 29 April 2020. Any idea why the application is behaving like that?


date.PNG

Scott Hunter

unread,
May 5, 2020, 7:52:30 AM5/5/20
to web2py-users
What do you mean by "redirected"?  If you just mean that the date field is reset to the current date, that is the same default behavior for all input fields.

Anuj Mahawar

unread,
May 5, 2020, 8:24:32 AM5/5/20
to web2py-users
Hey Scott, 
Yeah, I meant that the date is resetting to the current date even though I am selecting any previous date. Do you have any suggestions to change this default behavior?

Scott Hunter

unread,
May 5, 2020, 9:08:29 AM5/5/20
to web2py-users
If this is part of a form (which I have to guess at, since you have provided *no* details), you can use the `keepvalues` option to not reset the fields of a form.

Anuj Mahawar

unread,
May 6, 2020, 9:44:37 AM5/6/20
to web2py-users
Yes, its part of the SQLFORM. I have attached my file from the controller. Could you please let me know where do I need to make the changes (i.e. keepvalues = True)

Regards,
Anuj
default.py

Scott Hunter

unread,
May 6, 2020, 9:54:48 AM5/6/20
to web2py-users
Please identify what part of this rather long file is relevant to your question.  You might also want to look at the documentation for SQLFORM with regard ti how to use keepvalues.
Reply all
Reply to author
Forward
0 new messages