I have created custom module with custom form, in which I have added input type select. Form submission is working fine, but I wanted set select option value as custom class for BODY tag.

  • As per @samzha suggestion I used Switch Theme module and it's work fine for me, the only thing I need to create different themes for that. Dec 2, 2014 at 9:39

2 Answers 2


You can add through custom hook.

 function mytheme_preprocess_html(&$vars) {
  $vars['classes_array'][] = 'new-class';


function YOUR_THEME_preprocess_html(&$vars) {
  $path = 'your-drupal-page';
  if (drupal_match_path($_GET['q'], $path) || drupal_match_path(drupal_get_path_alias($_GET['q']), $path)) {
    $vars['classes_array'][] = 'page-my-css-class';

If you have any query related how to create then you can check this LINK.

  • Thanks for quick reply, but how do I get value of Selected option instead of 'new-class'? Dec 1, 2014 at 9:06
  • Means you want to select any option default SELECTED ???
    – Nishant
    Dec 1, 2014 at 9:10
  • I am trying to create option for user to change theme color using select list. Dec 1, 2014 at 9:12
  • Ok now I understand. You have some themes (Color) in your site & you want a select option & through this select option you need to jump one theme to another. Am I right ??
    – Nishant
    Dec 1, 2014 at 9:14
  • Yes, but instead of changing theme I want add class in Body tag Dec 1, 2014 at 9:19

Seems a pretty odd request and there might be a better way, please explain exactly what you're trying to achieve so a better solution could be offered.

Based upon your original post this could probably be achieved with the combination of Webform, Webform Rules, Rules, Context Rules & Context

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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