Change markup of single form field I have constructed a form manually using the Form API. I have one field in particular that needs to have it's markup changed a tad.

The #prefix/#suffix output should come immediately before/after the input control. I think the output currently looks like:

Can I override the themeing for a single field using something like:

$form['control'] = array(
  '#theme' =&gt; 'control_field',
  '#title' =&gt; 'Some title',
  '#type' =&gt; 'textfield'
);


Do I then implement MYTHEME_custom_theme in the templates.php???

Do you know of any exmaples I might use?

I tried adding:

function theme_control_field($variables) {

}


This did not seem to work...also I need control over all the markup for this field not just the field control but I need to relocate the prefix/suffix output as well!?!

Regards,
Alex
You can have a complete custom HTML for a particular field by defining a #theme and setting #theme_wrappers with an empty value.

$form['control'] = array(
  '#title' =&gt; 'Some title',
  '#type' =&gt; 'textfield'
  '#theme' =&gt; 'YOURMODULE_control_field',
  '#theme_wrappers =&gt; array(),
);


Then Drupal needs to know about this new theme by implementing the HOOK_theme. You can either work with a template file or generate the HTML within the theme callback function

function YOURMODULE_theme()
{
    return array(
        'YOURMODULE_control_field' =&gt; array(
            'template' =&gt; 'templates/control-field', // if you want to have a tpl file, templates/control-field.tpl.php using the $element variable for your textfield element
            'render element' =&gt; 'element',
        ),
    );
}

// If you dont want to use the template file
function theme_YOURMODULE_control_field($variables)
{
    $element = $variables['element'];
    // $element is here your form textfield element, this function return HTML to generate
}