[web2py] REF: SQLFORM in HTML
I am following the book example with modified tables, the form is not being processed in the controller, what could be wrong with my code below: *db.py [Model]* db.define_table(address, Field(street, requires=IS_NOT_EMPTY()), Field(suburb, requires = IS_NOT_EMPTY()), Field(town, requires = IS_NOT_EMPTY()), Field(province, requires = IS_NOT_EMPTY())) *default.py [Controller]* def add_address(): form = SQLFORM(db.address) if form.process(session=None, formname=test).accepted: response.flash = Address added elif form.errors: response.flash = Form has errors else: response.flash = Fill in form return dict() *add_address.html [View]* {{extend layout.html}} form table tr tdEnter street: /tdtdinput type=text name=street //td /tr tr tdEnter suburb: /tdtdinput type=text name=suburb //td /tr tr tdEnter town: /tdtdinput type=text name=town //td /tr tr tdEnter province: /tdtdinput type=text name=province //td /tr tr td colspan = 2input type=submit //td /tr /table input type=hidden name=_formname value=test / /form Regards, Teddy L. -- --- 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/groups/opt_out.
Re: [web2py] REF: SQLFORM in HTML
Hi Teddy, On 28/02/13 06:51, Teddy Nyambe wrote: I am following the book example with modified tables, the form is not being processed in the controller, what could be wrong with my code below: I think it's the way you have constructed your form: - *add_address.html [View]* {{extend layout.html}} form table tr tdEnter street: /tdtdinput type=text name=street //td /tr tr tdEnter suburb: /tdtdinput type=text name=suburb //td /tr tr tdEnter town: /tdtdinput type=text name=town //td /tr tr tdEnter province: /tdtdinput type=text name=province //td /tr tr td colspan = 2input type=submit //td /tr /table input type=hidden name=_formname value=test / /form See the sections in the book on hidden fields: - http://web2py.com/books/default/chapter/29/07#Hidden-fields ...and custom forms: - http://web2py.com/books/default/chapter/29/07#Custom-forms In your case, I think that the specific problem is the lack of the _formkey field. You can still customise your form but use {{=form.custom.begin}} and {{=form.custom.end}}. HTH -- Regards, PhilK 'a bell is a cup...until it is struck' -- --- 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/groups/opt_out.
Re: [web2py] REF: SQLFORM in HTML
Hi Teddy, Ignore my last - I'd overlooked that you were using session=None. I'll drink more coffee! N.B. Using SQLFORM that way turns off some valuable protection. As your other reply suggests, the lack of a form action may be the issue. -- Regards, PhilK 'a bell is a cup...until it is struck' -- --- 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/groups/opt_out.