Search code examples
drupaldrupal-themes

drupal theme checkboxes


I'm trying to us the theme hook the style some checkboxes. I have used the form_alter hook to make some changes to the labels of each checkbox and now i would like to interact with the checkbox theme function to style the labels.

In the form array it says

#theme (String, 20 characters ) select_as_checkboxes

is this the function i need to override? And how do i do this? I tried stuff like

function mymodule_select_as_checkboxes()

but i can't get it to work


Solution

  • Solution:

       function my_module_theme_registry_alter(&$theme_registry) {
          // Register theme_function to use the module custom function
          if (!empty($theme_registry['select_as_checkboxes'])) {
            $theme_registry['select_as_checkboxes']['function'] = 'my_module_select_as_checkboxes';
          }
        }
    

    Then in the function my_module_select_as_checkboxes create your own function or adapt the original one.