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.
2 Answers
You can add through custom hook.
function mytheme_preprocess_html(&$vars) {
$vars['classes_array'][] = 'new-class';
}
OR
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
-
-
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 ??– NishantDec 1, 2014 at 9:14
-
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