1

I have an existing webform in Drupal 7 which I am trying to theme. So far I managed to add CSS classes, placeholders, prefix, suffix,.. to form elements (fields) but not to the actual <form>-tag?

I tried this:

$form['#attributes']['class'][] = 'form-horizontal';`

But that didn't change anything to the output.

edit: I have found that putting var_dump($form['#attributes']); displays the array below the form-tag. Does that mean that you cannot alter the root element inside a template file (webform-form-8.tpl.php) and that I should implement the hook in template.php?

2 Answers 2

0

I believe your edit is correct. You should add the class in a preprocessor function within template.php.

A similar question and answer can be found here.

0
0
function THEME_form_alter(&$form, &$form_state, $form_id) {
    $form['#attributes']['class'][] = 'my_class';
}

in a template.php

Your Answer

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

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