I need to theme certain form fields on the user profile form page differently from other fields, for which I am trying to create a theme function that outputs html its own way, not using theme_form_element(). The reason for defining a new theme function alternative to theme_form_element() is because the html output is dramatically different.
This is my code:
function mymodule_theme() {
return array(
'profile_form_element' => array(
'variables' => array(
'element' => NULL,
),
),
);
}
function mymodule_form_user_profile_form_alter(&$form, &$form_state) {
$form['field_user_first_name']['#theme'] = 'profile_form_element';
dpm($form['field_user_first_name']);
}
function theme_profile_form_element(&$variables) {
$element = &$variables['element'];
// my html processing would start here...
}
...but the theme function has NULL for $variables['element']. What am I doing wrong? I am attaching the structure of my form field (field_user_first_name), which was created through the UI at configuration > people > account settings > manage fields.