Skip to main content
1 of 3
Lester Peabody
  • 4.5k
  • 6
  • 46
  • 81

Access the label for a form element via hook_form_alter

I have a form with id equal to webform_client_form_3. I have a particular field that I'm altering by applying a class to it like so:

$form['submitted']['estimated_annual_distribution_of_effort']['sensor_technology']['#attributes']['class'][] = 'span1';

This all works great. However, I also need to add a class on to the label for that particular element as well. Looking through the $form array, I haven't been able to find anything that gives access to the labels. Am I just missing something or are the labels not part of the $form array?

Lester Peabody
  • 4.5k
  • 6
  • 46
  • 81