I have run my test app (see previous post) with keepvalues=True and
keepvalues=False, both update views and loads of combinations of true/
false checkboxes with the following results.

1) whatever the test, the database was always updated as expected.

2) when keepvalues=False, the form values after submit were always as
expected.

3) when keepvalues=True, the form values after submit were as expected
with 2 exceptions:
[T=true/checked, F=false/unchecked, T/F in brackets=value of non-
displayed field]

a) in the 'update' view (3 checkboxes), when TTT changed to FFF then
database=FFF but form displays TTT (should be FFF?)

b) in the 'update2' view (just gsoh displayed), when (TT)T changed to
(TT)F then database=TTF but form displays (TT)T (should be TTF?)

I have run these tests several time with consistent results.  Am I
correct to identify the above as exceptions/wrong results?

On Nov 22, 1:23 am, mdipierro <[EMAIL PROTECTED]> wrote:
> That is because a form is reset to default upon accept, unless you
> accept with keepvalues=True.
>
> Massimo
>
> On Nov 21, 5:41 pm, billf <[EMAIL PROTECTED]> wrote:
>
> > I have been going back to basics and running my own test - just web2py
> > - and I agree that it does all seem to work ok (correct data on db and
> > correct data in form) with one exception (see next para).  I think I
> > overlooked the fact that, for standard form processing, update() only
> > updates the fields specified in "fields=" - custom forms are as you
> > say a different case.
>
> > My test app is as follows:
> > db.py
> > db=SQLDB('mysql://user:[EMAIL PROTECTED]:3306/chekov')
>
> > db.define_table('bloke',
> >     SQLField('name','string'),
> >     SQLField('married','boolean',default=False),
> >     SQLField('solvent','boolean',default=True),
> >     SQLField('gsoh','boolean'))
>
> > default.py
> > def index():   # display a create form plus a list of blokes
> >     form=SQLFORM(db.bloke)
> >     if form.accepts(request.vars):
> >         response.flash='OK'
> >     records=SQLTABLE(db().select(db.bloke.ALL),linkto=URL
> > (r=request,f='update'))
> >     return dict(form=form,records=records)
>
> > def update():  # an update form containing all fields plus a list of
> > blokes
> >     record=db(db.bloke.id==request.args[-1]).select(db.bloke.ALL)[0]
> >     form=SQLFORM(db.bloke,record)
> >     if form.accepts(request.vars):
> >         response.flash='OK'
> >     records=SQLTABLE(db().select(db.bloke.ALL),linkto=URL
> > (r=request,f='update2'))
> >     return dict(form=form,records=records)
>
> > def update2():  # an update form with just name and gsoh plus a list
> > of blokes
> >     record=db(db.bloke.id==request.args[-1]).select(db.bloke.ALL)[0]
> >     form=SQLFORM(db.bloke,record,fields=['name','gsoh'])
> >     if form.accepts(request.vars):
> >         response.flash='OK'
> >     records=SQLTABLE(db().select(db.bloke.ALL),linkto=URL
> > (r=request,f='update'))
> >     return dict(form=form,records=records)
>
> > The only anomaly I found was that in update2 (the form that only
> > displays 1 of 3 checkboxes), after submit, db correct, the list is
> > displayed correctly but the form checkbox setting is not always
> > correct - it seems always to be the original value as opposed to the
> > new value.  The 'update' form that displays all 3 checkboxes isn't
> > affected in this way and always displays the new values.
>
> > On Nov 21, 10:10 pm, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > > Good point. There is no way to get rid of the delete box in T2. we
> > > need a pacth!
>
> > > The exposes is in the t2 manual. At the end.
>
> > > On Nov 21, 3:40 pm, "Wes James" <[EMAIL PROTECTED]> wrote:
>
> > > > Massimo,
>
> > > > thx, this works.  I noticed with sqlform that I can do deletable=False
> > > > (i guess to get rid of delete checkbox)
>
> > > > How is this done with t2?
>
> > > > Also, I looked for exposed and exposes in the t2/web2py manuals and I
> > > > don't see these.
>
> > > > -wj
>
> > > > On Fri, Nov 21, 2008 at 1:47 PM, mdipierro <[EMAIL PROTECTED]> wrote:
>
> > > > > You are doing something evil in page1.html: {{=form[0][0][1]}}
>
> > > > > Anyway, given your custom forms and I assume you do not want to change
> > > > > them. you need to replace
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to