Still doesn't work. Says I'm missing _formkey. Also worth noting.... right when I get to the form it says 'please fill out the form' as in its processing the else already before it even accepts the data...
On Monday, May 5, 2014 11:13:09 AM UTC-4, Richard wrote: > > You miss this part in what you show me : > > if form.process().accepted: > response.flash = 'form accepted' > elif form.errors: > response.flash = 'form has errors' > else: > response.flash = 'please fill out the form' > > > > Avoid using user_signature at the begining, and you can add this more > secure thing latter on. > > Richard > > > > On Mon, May 5, 2014 at 10:40 AM, LoveWeb2py <atayl...@gmail.com<javascript:> > > wrote: > >> I've read that, Richard. >> >> When using this I get that error: >> >> def transition_form(): >> for f, v in request.vars.iteritems(): >> db.users[f].default = v >> form = SQLFORM(db.users, user_signature=True) >> >> if form.process().accepted: >> response.flash = 'form accepted' >> return dict(form=form) >> >> Still get the same error : >> <type 'exceptions.AttributeError'> 'Table' object has no attribute >> '_formkey' >> >> >> On Monday, May 5, 2014 10:34:28 AM UTC-4, Richard wrote: >> >>> That what I thought! >>> >>> How do you validate your form?? >>> >>> Please read the book a bit more about form submission... >>> >>> >>> >>> http://web2py.com/books/default/chapter/29/07/forms- >>> and-validators#SQLFORM >>> >>> def display_form(): >>> form = SQLFORM(db.person) >>> if form.process().accepted: >>> response.flash = 'form accepted' >>> elif form.errors: >>> response.flash = 'form has errors' >>> else: >>> response.flash = 'please fill out the form' >>> return dict(form=form) >>> >>> >>> You need to process the form, see if it validate... You shouldn't have >>> to insert manually your data if you don't need facy thing and >>> form.process().accepted should handle everything for you. >>> >>> Richard >>> >>> >>> >>> On Mon, May 5, 2014 at 10:03 AM, LoveWeb2py <atayl...@gmail.com> wrote: >>> >>>> Sorry forgot to add .iteritems(): this is the most updated version. >>>> >>>> >>>> On Monday, May 5, 2014 10:01:46 AM UTC-4, LoveWeb2py wrote: >>>> >>>>> Hi Richard, >>>>> >>>>> Here is what I have so far: >>>>> >>>>> Controllers: >>>>> def user_list(): >>>>> grid=SQLFORM.smartgrid(db.users, paginate=20, >>>>> links_placement='left', _href=URL('transition_form', vars=dict((f, >>>>> row[f]) >>>>> for f in db.users.fields))))], user_signature=True) >>>>> return dict(grid=grid) >>>>> >>>>> def transition_form(): >>>>> for f, v in request.vars.iteritems(): >>>>> >>>>> db.table[f].default = v >>>>> form = SQLFORM(db.table, user_signature=True) >>>>> return dict(form=form) >>>>> >>>>> View: >>>>> user_list.html >>>>> {{=form}} >>>>> >>>>> This properly populates the values. but it isn't submitting properly. >>>>> After the form submits I would like it to return to the database and show >>>>> me the user that was just added. Also, I set my database to autoincrement >>>>> the ID which should solve the "id problem" >>>>> >>>>> I was thinking I could set something in my transition_form function >>>>> that if form.process().accepted: redirect(URL('user_list')), but I get an >>>>> error saying table object has no attribute '_formkey' does this mean I >>>>> need >>>>> to do some type of form validation? >>>>> >>>>> On Monday, May 5, 2014 9:53:38 AM UTC-4, Richard wrote: >>>>>> >>>>>> Please show code!! >>>>>> >>>>>> Richard >>>>>> >>>>>> >>>>>> On Mon, May 5, 2014 at 8:50 AM, LoveWeb2py <atayl...@gmail.com>wrote: >>>>>> >>>>>>> Also, >>>>>>> >>>>>>> When I click the submit button in {{=form}} it doesn't actually >>>>>>> submit anything. It just doubles the values that are already in the >>>>>>> fields >>>>>>> and puts them into a list. I think I need to do something like >>>>>>> db.insert >>>>>>> with a new ID number for the submit button. >>>>>>> >>>>>>> >>>>>>> On Monday, May 5, 2014 8:46:25 AM UTC-4, LoveWeb2py wrote: >>>>>>>> >>>>>>>> Richard/Niphold, >>>>>>>> >>>>>>>> Thank you so much. It's almost done. Just getting attribute error >>>>>>>> now but I am going to try to fix that with exception handling. >>>>>>>> >>>>>>>> <type 'exceptions.AttributeError'> 'str' object has no attribute >>>>>>>> 'year' >>>>>>>> >>>>>>>> I have a modified_on field which is set to datetime. WHen I comment >>>>>>>> that out it transfers to the next page with no problem. Any thoughts >>>>>>>> on how >>>>>>>> I could fix? >>>>>>>> >>>>>>>> On Sunday, May 4, 2014 9:10:55 AM UTC-4, Richard wrote: >>>>>>>>> >>>>>>>>> Sorry for miss leading, Niphold is true... >>>>>>>>> >>>>>>>>> So, >>>>>>>>> >>>>>>>>> for f, v in request.vars.iteritmes(): >>>>>>>>> db.table[f].default = v >>>>>>>>> >>>>>>>>> >>>>>>>>> On Sat, May 3, 2014 at 8:47 AM, Niphlod <nip...@gmail.com> wrote: >>>>>>>>> >>>>>>>>>> request.vars is like a dict. Surely you're hitting that issue :-P >>>>>>>>>> >>>>>>>>>> >>> test = dict(a=1,b=2) >>>>>>>>>> >>> for k,v in test: >>>>>>>>>> ... print k, v >>>>>>>>>> ... >>>>>>>>>> Traceback (most recent call last): >>>>>>>>>> File "<stdin>", line 1, in <module> >>>>>>>>>> ValueError: need more than 1 value to unpack >>>>>>>>>> >>> >>>>>>>>>> >>>>>>>>>> Add an "iteritems()" and you're good to go >>>>>>>>>> >>>>>>>>>> >>> for k,v in test.iteritems(): >>>>>>>>>> ... print k,v >>>>>>>>>> ... >>>>>>>>>> a 1 >>>>>>>>>> b 2 >>>>>>>>>> >>>>>>>>>> >>> >>>>>>>>>> >>>>>>>>>> On Friday, May 2, 2014 11:20:40 PM UTC+2, LoveWeb2py wrote: >>>>>>>>>>> >>>>>>>>>>> Web2py admin console has a red line at for f, v in request.vars: >>>>>>>>>>> and then says too many values to unpack. >>>>>>>>>>> >>>>>>>>>>> my function is def transition_form(): >>>>>>>>>>> for f, v in request.vars: >>>>>>>>>>> db.table[f].default = v >>>>>>>>>>> form = SQLFORM(db.table, user_signature=True) >>>>>>>>>>> return dict(form=form) >>>>>>>>>>> >>>>>>>>>>> Should I have extra values in the dict method? >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> 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+un...@googlegroups.com. >>>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>> 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+un...@googlegroups.com. >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >>>> 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+un...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> 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+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/d/optout.