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'}}
My Test Form
{{=form1}}
{{=form2}}
Now modify the view to a custom form and form1 will no longer submit:
*View*
{{extend 'layout.html'}}
My Test Form
{{=form1.custom.begin}}
First Name
{{=form1.custom.widget.first_name}}
Last Name
{{=form1.custom.widget.last_name}}
E-mail Address
{{=form1.custom.widget.email}}
{{=form1.custom.submit}}
{{=form1.custom.end}}
{{=form2.custom.begin}}
User_ref
{{=form2.custom.widget.user_ref}}
Address
{{=form2.custom.widget.address_line}}
{{=form2.custom.submit}}
{{=form2.custom.end}}
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.
You can modify the custom auth form to use {{=form1.hidden_fields()}} and
manually close the form with and this will provide a work around.
Just wanted to make you aware of this if you weren't already.
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.