Theming forms on alter with Drupal 7 I'm having issues customizing a radio button for a specific form using hook_theme.  Below is the piece of code I have on my module; see my comments elaborating the issue I encounter:

// Implementation of hook_form_alter().
function mymodule_form_alter(&amp;$form, $form_state, $form_id){
  // e.g form id: commerce_cart_add_to_cart_form_u6onPJSgS7pOgw0Tlo7zHy42LTQzbV913taANkYQKTo
  if (strpos($form_id, 'commerce_cart_add_to_cart_form') !== FALSE) {
    // Alter add to cart form
    mymodule_commerce_cart_add_to_cart_form_alter($form, $form_state, $form_id);
  }
}

function mymodule_commerce_cart_add_to_cart_form_alter(&amp;$form, $form_state, $form_id) {     
  // Change the field type to radios.
  $form['attributes']['field_artwork_ref']['#type'] = 'radios';
  // Apply my custom theme for radios.
  $form['attributes']['field_artwork_ref']['#theme'] = array('custom_radios');      
}

// Implementation of hook_theme().
function mymodule_theme() {
  return array(
    'custom_radios' =&gt; array(
      'variables' =&gt; array('element' =&gt; NULL),
    ),
  );
}

function theme_custom_radios($variables) {
  // Custom theme should go here.
  // However, $variables are empty, print_r gives me "Array ( [element] =&gt; )."
  // I am at least expecting to see my radio element here. 
  print_r($variables);      
}
I found this answer for Theming forms on alter with Drupal 7 on Stack Overflow: 


  Themes for Drupal 7 form elements need to use the new render array key instead of variables in the theme definition:

function mymodule_theme() {
  return array(
    'custom_radios' =&gt; array(
      'render element' =&gt; 'element',
    ),
  );
}

  
  Once you've made the change, clear Drupal's caches and your code should work (I've just tested the above and it works fine).