You could put all that in a function within the user() function or imported 
from a module:

def custom_login_form(form):
    [code to manipulate form]

login_form = auth.login()
custom_login_form(login_form)

Or as Massimo suggests, you can just build a custom form in the view. If 
you need the form in multiple places, you can put it in its own view file 
(e.g., login_form.html) and then do {{include 'login_form.html'}} wherever 
you need it to be inserted.

Some other suggestions:

for label in form.elements('label'):
>     if label[-1]!='Remember me (for 30 days)':
>         label["_style"] = "display:none;"
>
>
If you don't want the "Remember me" option available, just do:

auth.settings.remember_me_form = False
 

> email = {"email": "email address",}
> pwd = {"password": "password"}for input in form.elements("input[type=text]"):
>     input["_placeholder"] = email.get(input["_name"], "")for input in 
> form.elements("input[type=password]"):
>     input["_placeholder"] = pwd.get(input["_name"], "")
>
>
Why not just:

form.element(_name='email')['_placeholder'] = 'email address'
form.element(_name='password')['_placeholder'] = 'password'

or:

db.auth_user.email.widget = lambda f, v: SQLFORM.widgets.string.widget(f, 
v,_placeholder
='email address')

The above is a trick for passing additional attributes to the various form 
widgets.

form.elements('input[type=submit]')[0]["_value"] = "Login"
> form.elements('input[type=submit]')[0]["_class"] = "btn btn-large btn-primary"
>
>
form.element(_type='submit').update(_value='Login', _class='btn btn-large 
btn-primary')

Note, .element() is the same as .elements() but returns the first matching 
element (useful if there is only one matching element, so you don't then 
have to subscript the result).

Anthony

-- 



Reply via email to