Thank you Anthony. Once the process() is removed it works correctly. On Sunday, March 27, 2016 at 9:43:22 AM UTC-7, Stuart Rolinson wrote: > > I think I may have found a bug when rendering custom auth forms using > SQLFORM. > When the auth profile form is rendered using form.custom.begin - > form.custom.end the hidden fields are rendered incorrectly causing the > form not submit correctly. > > The following code works correctly: > > *Model* > > db.define_table('address', > Field('user_ref', 'reference auth_user'), > Field('address_line', type='string', length=128)) > > *Controller* > > def test(): > form1 = auth.profile() > row=db(db.address.user_ref==auth.user_id).select().first() > form2 = SQLFORM(db.address, record=row) > > if form1.process().accepted: > response.flash='form 1 saved' > if form2.process().accepted: > response.flash='form 2 saved' > > return dict(form1=form1, form2=form2) > > *View* > {{extend 'layout.html'}} > <h1>My Test Form</h1> > > {{=form1}} > <hr> > {{=form2}} > > > > Now modify the view to a custom form and form1 will no longer submit: > > *View* > {{extend 'layout.html'}} > <h1>My Test Form</h1> > > <div class='form-horizontal'> > {{=form1.custom.begin}} > <div class='form-group'> > <div class='col-sm-3 control-label'> > First Name > </div> > <div class='col-sm-9'> > {{=form1.custom.widget.first_name}} > </div> > </div> > > <div class='form-group'> > <div class='col-sm-3 control-label'> > Last Name > </div> > <div class='col-sm-9'> > {{=form1.custom.widget.last_name}} > </div> > </div> > > <div class='form-group'> > <div class='col-sm-3 control-label'> > E-mail Address > </div> > <div class='col-sm-9'> > {{=form1.custom.widget.email}} > </div> > </div> > > <div class='form-group'> > <div class='col-sm-9 col-sm-offset-3'> > {{=form1.custom.submit}} > </div> > </div> > {{=form1.custom.end}} > </div> > > > <hr> > > <div class='form-horizontal'> > {{=form2.custom.begin}} > <div class='form-group'> > <div class='col-sm-3 control-label'> > User_ref > </div> > <div class='col-sm-9'> > {{=form2.custom.widget.user_ref}} > </div> > </div> > > <div class='form-group'> > <div class='col-sm-3 control-label'> > Address > </div> > <div class='col-sm-9'> > {{=form2.custom.widget.address_line}} > </div> > </div> > > <div class='form-group'> > <div class='col-sm-9 col-sm-offset-3'> > {{=form2.custom.submit}} > </div> > </div> > {{=form2.custom.end}} > </div> > > > If you look at the source of this form, there are two hidden sections at > the end of the auth form with different _formkey values instead of one. > This form will not submit and process, but form form 2 works perfectly. > > <div style="display:none;"><input name="_next" type="hidden" value=" > /test/default/index" /><input name="id" type="hidden" value="1" /><input > name="_formkey" type="hidden" value="7d82bb1c-bbab-4dcc-a2a6-8bcec41b4090" > /><input name="_formname" type="hidden" value="auth_user/1" /></div> > > <div style="display:none;"><input name="_next" type="hidden" value=" > /test/default/index" /><input name="id" type="hidden" value="1" /><input > name="_formkey" type="hidden" value="aa31556e-d366-4b3a-aa81-434c1eabdbc5" > /><input name="_formname" type="hidden" value="profile" /></div></form> > > You can modify the custom auth form to use {{=form1.hidden_fields()}} and > manually close the form with </form> and this will provide a work around. > Just wanted to make you aware of this if you weren't already. > </div> > > Kind regards, > Stuart > >
-- 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.