0

I want to add a table class to all the tables, automatically. How can I achieve this by overriding a theme function?

  • 2
    Given the form requires an _alter() and this requires a _preprocess(), I think they both should stand; otherwise, I'm almost certain someone would complain about asking two questions at the same time. – Jimajamma Jan 20 '14 at 15:57
  • 2
    Now there is just a missing question about adding a CSS class to a form element created with the FAPI, and we covered up all the cases. :) – kiamlaluno Jan 20 '14 at 16:20
5

If your table is rendered using theme('table'), you can preprocess it from your theme function.

function my_theme_preprocess_table(&$variables) {
  $variables['attributes']['class'][] = 'table';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.