Clear example on how to use #theme for form API I cannot find a good example of how to accomplish custom theming on a field level within a form:

$form['test_2'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Test Field #2'),
  '#required' =&gt; true,
  '#description' =&gt; t('This is a test field which we hook into.'),

  '#theme' =&gt; 'custom_func'
);


Inside my template.php I have:

function MYTHEME_theme() {
    return array(
      'custom_func' =&gt; array(
        'render element' =&gt; ??? // WTF goes here???
      )
    );
}

function MYTHEME_custom_func($variables) {
  return 'Something';
}


This code obviously does not work...what am I missing?
You're so close...the name of the render element is arbitrary, it's just a name so you can pick it up at the other end. Or, put more eloquently:


  The name of the renderable element or element tree to pass to the theme function. This name is used as the name of the variable that holds the renderable element or tree in preprocess and process functions.


So:

function MYTHEME_theme() {
  return array(
    'custom_func' =&gt; array(
      'render element' =&gt; 'my_element',
    ),
  );
}

function MYTHEME_custom_func($variables) {
  $element = $variables['my_element'];

  // Use the values in the $element render array to build markup.

  return $element;
}