I'm creating a simple twitter like app for fun. To submit worked with
{{=form}} and now I'm using form.custom.xxx for customization.
It works fine if I comment out the following from default.py but
form.vars will be empty and the record will not be created with the
two lines.
if form.accepts(request.vars, session):
redirect(URL())
Any idea what's happening and do you know how to solve this problem?
db.py
----------
db.define_table('comment',
Field('body', 'text', length=140),
Field('created_on', 'datetime', default=request.now),
Field('created_by', db.auth_user, default=auth.user_id,
ondelete='NO ACTION'))
db.comment.body.requires = IS_NOT_EMPTY()
db.comment.created_on.writable = db.comment.created_on.readable =
False
db.comment.created_by.writable = db.comment.created_by.readable =
False
default.py
---------------------
@auth.requires_login()
def index():
comments = db().select(db.comment.ALL,
orderby=~db.comment.created_on)
form = crud.create(db.comment)
if form.accepts(request.vars, session):
redirect(URL())
return dict(comments=comments, form=form)
default/index.html
----------------------------------
{{extend 'layout.html'}}
<h1>What's happening ?</h1>
{{=form.custom.begin}}
{{=form.custom.widget.body}}
{{=form.custom.submit}}
{{=form.custom.end}}
{{=BEAUTIFY(request.vars)}}
{{=form.vars}}
<h1>What's happened ?</h1>
{{for comment in comments:}}
<div><b>{{=db.auth_user[comment.created_by].first_name}}
{{=db.auth_user[comment.created_by].last_name}}</b> - {{=comment.body}}
</div>
<br/>
{{pass}}