Add attribute to all textboxes in the site The question is simple , in my theme I want to apply an attribute to all textboxes in whole forms . I know how to add an attribute to an specific element in drupal using hook_form_alter , but it is too time consuming for lots of elements , so I'm eager to see if there is an easier way to do that.Any suggestion?
You'll want to use hook_field_widget_WIDGET_TYPE_form_alter() for this. The following will add the "my-class" class to all textfields:

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function test_field_widget_text_textfield_form_alter(&amp;$element, &amp;$form_state, $context) {
  $element['value']['#attributes']['class'][] = 'my-class';
}