Add a class to all title text fields in all content add forms I'm using Twitter Bootstrap and I want to expand the length of all the title fields in the content forms by adding 'span6' to the class attribute for the title field's input element.

I've added the following function to my template.php file:

function ccom_field__title($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '&lt;div class="field-label"' . $variables['title_attributes'] . '&gt;' . $variables['label'] . ':&amp;nbsp;&lt;/div&gt;';
  }

  // Render the items.
  $output .= '&lt;div class="field-items"' . $variables['content_attributes'] . '&gt;';
  foreach ($variables['items'] as $delta =&gt; $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '&lt;div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '&gt;' . drupal_render($item) . '&lt;/div&gt;';
  }
  $output .= '&lt;/div&gt;';

  // Render the top-level DIV.
  $output = '&lt;div class="' . $variables['classes'] . '"' . $variables['attributes'] . '&gt;' . $output . '&lt;/div&gt;';

  return $output;
}


Right now all I've done to it is change the name of the function according to the functions preceding comment.  I'm not sure what I need to do, because I need to add the class to the input element directly, and not its parent div element.

Using JavaScript (including jQuery) is not an option.

TL;DR

How does one add a class to a specific field's input element?
The content title is a property rather than a field, so overriding theme_field() isn't the way to do this.

Instead you might want to use a hook_form_FORM_ID_alter() (which can also be used in your theme's template.php file):

function ccom_form_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['title']['#attributes']['class'][] = 'span6';
}