Awsome !! I replaced with this and it work!
form = crud.create(db.comment, next=URL(''))On Sep 7, 3:54 pm, Jim Steil <[email protected]> wrote: > Just add the 'next' parameter to the crud.create statement. > > You can see the details here: > > http://www.web2py.com/book/default/chapter/07#CRUD > > Scroll down and look under Methods. > > -Jim > > On 9/7/2011 3:51 PM, Omi Chiba wrote: > > > > > > > > > Thank you, Anthony ! > > > I still want to do "redirect(URL())" if the entry is accepted. > > Can you explain what condition I should use instead of form.accepts in > > default.py ? > > > It's necessary to refresh the list on the page. > > > On Sep 7, 3:40 pm, Anthony<[email protected]> wrote: > >> If you are using crud, you should not do form.accepts -- crud.create will > >> handle the form.accepts for you. > >> Seehttp://web2py.com/book/default/chapter/07#CRUD. > > >> Anthony > > >> On Wednesday, September 7, 2011 4:29:24 PM UTC-4, Omi Chiba wrote: > > >>> 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}}

