form=SQLFORM(db.table)
if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return dict(form=form)
You may need to include the form's hidden fields in your view. Does {{=form.hidden_fields()}} work? See here: https://groups.google.com/d/msg/web2py/k5D19CHB2TU/9Ll7ly5ZOK4J
Thanks Anthony for trying to help.Lol, I don't know I even mentioned CSS. Just to clarify, yes, I get the "invalid login" flash alert. I put the code as posted here in my layout.html file. I have the issue regardless of the page I am on.
This is the code as it appears in the layout:
{{if not auth.user:}}<div id="loginForm">
{{form=auth.login()}}{{=form.custom.begin}}Username:{{=form.custom.widget.username}}</br>Password:{{=form.custom.widget.password}}{{=form.custom.submit}}
{{=form.hidden_fields()}}{{=form.custom.end}}</div>{{pass}}
On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:
{{=registrationForm}}
The registraionForm does not allow me to register a new user if the line that changes the name of the #user_username id exists in the controller. Once you remove it, the registration form starts to work fine. The same occurs with the login form. If you change the name of the username or password field, it doesn't allow you to log in.
The reason I'd like to change the name of the username field is that it is the same as the one on the login form, and if you happen to have both on the same page, you may encounter issues with jQuery/Ajax functions that pass along their values.
if request.post_vars.regForm_username:
request.post_vars.username = request.post_vars.regForm_username
registrationForm = auth.register()
This is in my controller:registrationForm = auth.register()UN = registrationForm.element("#user_username")UN["_placeholder"] = "Username"UN["_name"] = "regForm_username" # This is what causes the error.and this is in my view:{{=registrationForm}}
The registraionForm does not allow me to register a new user if the line that changes the name of the #user_username id exists in the controller. Once you remove it, the registration form starts to work fine. The same occurs with the login form. If you change the name of the username or password field, it doesn't allow you to log in.
The reason I'd like to change the name of the username field is that it is the same as the one on the login form, and if you happen to have both on the same page, you may encounter issues with jQuery/Ajax functions that pass along their values.
On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:
Thanks Anthony, I didn't know you could use jQuery selectors for the second argument. One more question:
Is it possible to generate the remember me checkbox using the form.custom.widget, or I should create my own checkbox?
form.element('#auth_user_remember').parent
form.element('#auth_user_remember__row')
<form class="form-horizontal"> <form action="" enctype="multipart/form-data" method="post">
To avoid this, how can I tell web2py that the login form's style has to be form-horizontal?
That way it can generate the HTML automagically.
I tried the following in my controller but it's still not working:
def login():
form = auth.login()
form['_class']='form-horizontal'
return dict(form=form)
I'd eventually also like to style the Login button and the "Remember me for X days" checkbox.
Thanks!
#view html
{{extend 'layout.html'}}
{{
# add class to form
form['_class'] = "form-horizontal"
# change form.custom.begin
form.custom.begin = XML("<%s %s>" % (form.tag, form._xml()[0]))
}}
{{=form.custom.begin}}
your content form
{{=form.custom.end}}
def login():
auth.settings.formstyle = 'bootstrap'
form = auth.login()
return dict(form=form)
{{=form}}
Ah ok I just took a look at the HTML and saw that my code conflicts with what web2py is generating.
Basically there's a form within a form being constructed, so it looks like this:<form class="form-horizontal"> <form action="" enctype="multipart/form-data" method="post">
To avoid this, how can I tell web2py that the login form's style has to be form-horizontal?
That way it can generate the HTML automagically.
I tried the following in my controller but it's still not working:
def login():
form = auth.login()
form['_class']='form-horizontal'
return dict(form=form)
I'd eventually also like to style the Login button and the "Remember me for X days" checkbox.
Thanks!
On Wednesday, August 15, 2012 6:51:12 AM UTC+1, shartha wrote:
XML("<%s %s>" % (form.tag, form._xml()[0]))