This is good for me. Thanks for the help On Thu, 16 Aug 2018 at 22:40, Dave S <snidely....@gmail.com> wrote:
> > > On Thursday, August 16, 2018 at 1:53:18 AM UTC-7, Lovedie JC wrote: >> >> Sorry am trying to understand this statement: "If you're trying to look >> at the the row you just inserted, db.post.insert() returns the id of the >> new tuple, and that should allow your select() to be done by id." >> regards >> > > I'm guessing that you want something like > > def progress_view(): > form = SQLFORM(Post, formstyle='table3cols').process() > if form.errors or "name" not in request.vars: > response.flash = "please enter a name" > return dict(form = form, name = "", r_id = None) > r_id = db.post.insert(name=request.vars.name) > row = db.post(r_id) > return dict(form = form, name = row.name, id = r_id) > > I just noticed that you have Post in the SQLFORM() and post in the > separate insert. If these are both supposed to be Post (or both post), > then you don't need the separate insert, and the new row is > > r_id = form.vars.id > > > You might want to review chapters 6 and 7 of the book, because I think > you've made things more complicated than they should be. > > /dps > > > > > >> On Thu, 16 Aug 2018 at 01:05, Dave S <snide...@gmail.com> wrote: >> >>> >>> >>> On Wednesday, August 15, 2018 at 8:12:37 AM UTC-7, lbjc...@gmail.com >>> wrote: >>>> >>>> Am puzzled by this, that I cant post text from request.vars value to >>>> database and when refreshing, the text is there but I cant access this >>>> value to controller functions. >>>> This is my code: >>>> def progress_view(): >>>> form = SQLFORM(Post, formstyle='table3cols').process() >>>> if request.vars: >>>> r = [request.vars.name] >>>> codes.append(r[0]) >>>> db.post.insert(name=codes[0]) >>>> #db(db.post.id > 11).update(message=codes[0]) >>>> row = db(db.post.author== auth.user.id).select(db.post.id, >>>> db.post.name, orderby=~db.post.id, limitby=(0,1)).first() >>>> code = row.name if row else None >>>> return dict(code=code) >>>> Is there a way of accessing the CURRENT value from request.vars to >>>> controller ? like append to a list without refreshing the page >>>> Is there a javascript/jquery function that can do DAL refresh? >>>> >>> >>> I think there may be some confusion, because you *are* accessing the >>> current value of request.vars.name in the controller, >>> which you put in a list and assign to r. Perhaps you want to show it >>> in the *view*, but you aren't returning anything but code to the view. >>> code is set to row.name, where you take the first tuple of the select() >>> results (which are in reverse order). >>> >>> If you're trying to look at the the row you just inserted, >>> db.post.insert() returns the id of the new tuple, and that should allow >>> your select() to be done by id. >>> >>> If I misunderstood what you're trying to do, try explaining again what >>> your workflow is and what you want to happen. >>> >>> Dave >>> /dps >>> >>> >>> >>> >>> -- >>> 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+unsubscr...@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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.