[web2py] Problem with SQLFORM to add a record with some known field

2013-09-27 Thread Tao Wang
I'm just beginning to learn web2py. A beginner question about how to insert 
a record using sqlform

form = SQLFORM(db.filecomment, fields=['file_id', 'filecomment'])

I can get the file_id, so I do not need user to file this field. What the 
user only need to file the 'filecomment' field. How could I do this? In the 
above code, the user need to file both file_id and filecomment.
After form.process.accepted, the record will be inserted. 

Thanks

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Problem with SQLFORM

2011-10-05 Thread Guy Nesher
I want to add an upload form to a page (allow users to add
attachments)
I've basically copied the comment example (appears in chapter 3) but
use an upload field (instead of text) however I'm getting the
following error which doesn't really makes sense :
type 'exceptions.AttributeError'('SQLFORM' object has no attribute
'accepted')

This is the code :

@auth.requires_login()
def show():
project = db(db.project.id==request.args(0)).select().first()
form = SQLFORM(db.file)
form.project = project.id
if form.process().accepted:
session.flash = 'form accepted'
return dict(project=project, form=form)


Can't figure out what I'm missing, this should be quite straight
forward the . accepted appears in quite a few examples using this
exact code