How to implement custom theme functions like theme_textfield or theme_form_element?
I know we can do it using hook_theme_registry_alter:
/**
* Implements hook_theme_registry_alter().
*/
function krown_admin_theme_registry_alter(&$theme_registry) {
//Override some Drupal defaul theme functions
$theme_registry['textfield']['theme path'] = drupal_get_path('module', 'krown_admin');
$theme_registry['textfield']['function'] = 'krown_admin_theme_textfield';
$theme_registry['textarea']['theme path'] = drupal_get_path('module', 'krown_admin');
$theme_registry['textarea']['function'] = 'krown_admin_theme_textarea';
$theme_registry['form_element']['theme path'] = drupal_get_path('module', 'krown_admin');
$theme_registry['form_element']['function'] = 'krown_admin_theme_form_element';
$theme_registry['form_element_label']['theme path'] = drupal_get_path('module', 'krown_admin');
$theme_registry['form_element_label']['function'] = 'krown_admin_theme_form_element_label';
}
The problem with this approach, is that the custom functions are applied on all website. I just want to apply them for some forms or for a specific theme.