Getting more form, y'all

80 views
Skip to first unread message

Dave S

unread,
Jan 10, 2017, 6:04:13 PM1/10/17
to web2py-users
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

Dave S

unread,
Jan 11, 2017, 2:34:48 AM1/11/17
to web2py-users
On Tuesday, January 10, 2017 at 3:04:13 PM UTC-8, Dave S wrote:
 
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

Nope.

/dps
 
 

Dave S

unread,
Jan 16, 2017, 3:06:12 PM1/16/17
to web2py-users
My turn to wonder if someone has more of clue than I do.

/dps
 
 
 

António Ramos

unread,
Jan 18, 2017, 10:37:52 AM1/18/17
to web...@googlegroups.com
Dave, maybe next time you write a less generic "Subject"
It would be easier to find it.
Regards

--
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 web2py+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dave S

unread,
Jan 18, 2017, 2:06:49 PM1/18/17
to web2py-users
On Wednesday, January 18, 2017 at 7:37:52 AM UTC-8, Ramos wrote:
Dave, maybe next time you write a less generic "Subject"
It would be easier to find it.
Regards


I admit to having gone for cutesy in the subject line, but some of us read all the posts; where does "finding" come in?

/dps

 
2017-01-16 20:06 GMT+00:00 Dave S <snide...@gmail.com>:
On Tuesday, January 10, 2017 at 11:34:48 PM UTC-8, Dave S wrote:
On Tuesday, January 10, 2017 at 3:04:13 PM UTC-8, Dave S wrote:
 
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

Nope.

My turn to wonder if someone has more of clue than I do.

/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 web2py+un...@googlegroups.com.

António Ramos

unread,
Jan 18, 2017, 5:08:57 PM1/18/17
to web...@googlegroups.com
Forget my comment. .. moving on...

To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages