How to add class to individual radio item inside "radios"? I need to style my radios as tabs. So I created a form element like this:

$form['important_categories'] = array (
  '#type' =&gt; 'radios',
  '#label' =&gt; NULL,
  '#attributes' =&gt; array (
    'class' =&gt; array (
      'radioTabs',
    ),
  ),
);

foreach ($important_categories as $id_important_category =&gt; $important_category_name) {
  $form['important_categories']['#options'][$id_important_category] = $important_category_name;
  if(!isset($form['important_categories']['#default_value'])) {
    $form['important_categories']['#default_value'] = $id_important_category;
  }
}


This properly sets options, and sets first element as default. However, it add classes in two places. Here I wanted it:

&lt;div id="edit-important-categories" class="form-radios radioTabs"&gt;


Here I didn't:

&lt;input id="edit-important-categories-22" class="radioTabs form-radio" type="radio" value="22" name="important_categories"&gt;


On individual radio, I need radioTab (singular, not plural), and on default one also radioTabDefault.

Is there any built-in method to get this? Or do I need to alter my theme, like I did for labels? If so, what function I should modify?
No there's nothing built-in for this (take a look at form_process_radios(), nothing in there that would let you specify individual classes).

No need to hack core though like in the solution you linked to. Simply implement hook_element_info_alter(), and replace the process function with your own, which will be based on the original form_process_radios(), but that can handle individual classes for options.

function MYMODULE_element_info_alter(&amp;$info) {
  // You might want more advanced logic here, to replace instead of override altogether,
  // in case other modules have already altered the core info.
  $info['radios']['#process'] = array('MYMODULE_process_radios');
}

function MYMODULE_process_radios($element) {
  // ...
  return $element;
}