Read through the CRUD section of the book again: 
http://web2py.com/books/default/chapter/29/07#CRUD.

Crud automatically handles form processing, so you do not call 
form.process() after calling crud.create() -- in that case, you are 
processing the form twice. Instead, crud.create() handles the processing 
itself. If you want it to redirect, do:

crud.settings.create_next = URL('index')


as indicated in the book.

Anthony

On Sunday, December 2, 2012 4:15:51 PM UTC-5, jonas wrote:
>
> Hi.
>
> when using the code below redirect and verification doesn't work:
>
> def comment():
>
>     """ create comment form """
>
>     post=db(db.blog.id==request.args(0)).select().first()
>     db.comments.post_id.default=post.id
>     form=crud.create(db.comments)
>
>     if form.process().accepted:
> session.flash = T('yes yes')
>         redirect(URL('index.html'))
>     else:
>     print "error"
> session.flash = T('no no')
> raise HTTP(400, "no form validation")
>     
>     return dict(form=form)
>
> when I remove the if form... else... clause verification works but I don't 
> have the redirect anymore:
>
> def comment():
>
>     """ create comment form """
>
>     post=db(db.blog.id==request.args(0)).select().first()
>     db.comments.post_id.default=post.id
>     form=crud.create(db.comments)
>     
>     return dict(form=form)
>
> Have no clue why. please help. 
>

-- 



Reply via email to