Hello Massimo, May I use this SQLFORM.grid capability to create a bulk or batch insert feature?
I am having problem with form validation and update of record actually. I try to update a record for now : Controller : def grid_into_form(): grid = SQLFORM.grid(db.tab1, _class="web2py_grid", links=[lambda row: INPUT(_name='result', _class='decimal')], create=True, editable=True, paginate=5) return dict(grid=grid) View : <form>{{=grid}}<input type='submit'/></form> I get input for every records in the table. But since I use html form tag I wonder how I could use validators... I try to put the grid in a form at the controller level like this (not successfully) : def grid_into_form(): grid = SQLFORM.grid(db.tab1, _class="web2py_grid", links=[lambda row: INPUT(_name='result', _class='decimal')], create=True, editable=True, paginate=5) form = FORM(grid) if form.accepts(request,session): response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill the form' return dict(form=form) Also, how could I generate a grid of say 20 rows with only blank input for every fields of a given table (so kind of empty rows)? Thanks Richard On Wed, Apr 11, 2012 at 9:34 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > yes and not and what I said needs clarification. > > grid = SQLFORM.grid(create=False,update=False) is not a form. If > create=True or update=True then it contains a form when you are creating or > updating a record. you must avoind a form within a form and you can do so > in the view: > > {{if grid.create_form or grid.update_form:}} > {{=grid}} it is a form > {{else:}} > <form>{{=grid}} it is not a form but you can embed it in one <input > type='submit'/></form> > {{pass}} > > > On Wednesday, 11 April 2012 20:23:08 UTC-5, greenpoise wrote: >> >> A bit confused..I thought SQLFORM.grid was itself a form? Also, can I add >> more than one link per grid? Reading from the book, it creates a column so >> technically sounds as if I could??? >> >> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: >>> >>> You can put the grid in a form and you add >>> >>> SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) >>> >>> On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: >>>> >>>> Is this possible?? I have a products table that shows all the products. >>>> I also created an add to cart button in it problem is if I want to add 100 >>>> items I would have to press the button 100 times. Is there a way to add a >>>> quantity text field??? >>>> >>>> >>>> Thanks >>>> >>>> Dan >>>> >>> >> On Wednesday, 11 April 2012 16:27:17 UTC-7, Massimo Di Pierro wrote: >>> >>> You can put the grid in a form and you add >>> >>> SQLFORM.grid(..., link=[lambda row: INTPUT(...)]) >>> >>> On Wednesday, 11 April 2012 17:07:58 UTC-5, greenpoise wrote: >>>> >>>> Is this possible?? I have a products table that shows all the products. >>>> I also created an add to cart button in it problem is if I want to add 100 >>>> items I would have to press the button 100 times. Is there a way to add a >>>> quantity text field??? >>>> >>>> >>>> Thanks >>>> >>>> Dan >>>> >>>