By jyg on
This, in mymodule/mymodule.module will add 'my-new-class' into the class attribute of a <form>
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'my-new-form') {
$form['#attributes'] = array('class' => 'my-new-class');
}
}
This, in mytheme/template.php won't
function mytheme_my_new_form($form) {
$form['#attributes'] = array('class' => 'my-new-class');
return drupal_render($form);
}
If I use the hook_form_alter() method, I can see the class name added into the $form array if I dpm() from within template.php mytheme_my_new_form() override. OK, makes sense. However, I do not understand why, if I alter $form['#attributes'] from within the theme override that such changes never show up in the rendered form.
Can anyone explain this to me?
thanks,
jyg