Adding HTML5 placeholder to all drupal forms I'm trying to add the placeholder attribute to all textfields across my website, but I'm having no luck.

I've created a module that overrides hook_form_alter

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id)
{
    foreach ($form as $key =&gt; $value) {
        if ("textfield" == $value["#type"]){
            $value['#attributes']["placeholder"] = t($value["#title"]);
        }
    }
}


I should tell you that I'm also using the webform module.
Because I'm using the webform module I could just theme the global webform template (webform-form.tpl.php) and put it in my theme folder. No need to complicate things with a module.

foreach ($form["submitted"] as $key =&gt; $value) {
    if ("textfield" == $value["#type"]) {
        $form["submitted"][$key]['#attributes']["placeholder"] = t($value["#title"]);
    } 
}


I put this at the top of the template file.