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
-~----------~----~----~----~------~----~------~--~---