How do I replace all forms to use the HTML5 `placeholder` rather than `label`?

Here is how I currently do it:

def signup_form_function():
    signup_form = SQLFORM(db.auth_user)

    for label in signup_form.elements('label'):
        label["_style"] = "display:none;"

    placeholders = {
        "email": "email address",
        "expertise": "expertise; press `+` to add more ->",
    }
    pwd = {
        "password": "password"
    }
    for input in signup_form.elements("input[type=text]"):
        input["_placeholder"] = placeholders.get(input["_name"], "")

    for input in signup_form.elements("input[type=password]"):
        input["_placeholder"] = pwd.get(input["_name"], '')

    signup_form.elements('input[type=submit]')[0]["_value"] = "Signup"
    signup_form.elements('input[type=submit]')[0]["_class"] = "btn
btn-large btn-primary"

    if signup_form.process().accepted:
        response.flash = "foo"

    return signup_form

----------

But maybe this could be done at the schema level; e.g.: utilising the
label attribute of the Field tuple?

Thanks for all suggestions,

Alec Taylor

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to