How to add placeholder to all Drupal 7 text forms in node page? I'm trying to add the placeholders from field description to all Drupal 7 text forms only in node page using Drupal API

I've created a module that overrides hook_form_alter 

  &lt;?php
function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    if (isset($form['#node_edit_form']) &amp;&amp; $form['#node_edit_form'] == TRUE) {       
        foreach ($form as $key =&gt; $value) {
            if ($value == "textfield") {
            $form['type'][$value]['#attributes']['placeholder'] = $form['#description']; 
            unset($form['#description']);
            }  
        }
    }
}


?>

How to do it using Drupal Api without using JavaScript?
I take it by wanting a Placeholder that the text is going to be removed by javaScript when the use enters text ?

If so, there are a couple of modules for that, for example :
https://www.drupal.org/project/field_placeholder

This will give you an extra setting in the field setting form so you wont have to use your description, allowing it to be used for the description.