I need to theme the login form. I need additional css classes and tabindex for the form elements.
Now I have a problem with these both for the login button.
In template.php I use 'attributes' for that. For e.g. the password field it works perfect with this code:
$form['pass']['#attributes']['class'][] = 'input-sm form-control';
$form['pass']['#attributes']['tabindex'][] = '2';
When I use this for the button - nothing is rendered in html:
$form['op']['#attributes']['class'][] = 'test-button';
$form['op']['#attributes']['tabindex'][] = '3';
'op' is the name of the login button which I can see in html output.
How can I get the 'class' and 'tabindex' to the login button?
For the button you should use
$form['#submit']
.In any case you can use hook_form_alter() and devel's
dpm($form)
to get the form data. A generic example:The submit button may be accessed like this for a common Drupal theme (structure taken from the dpm() function):
One important thing here is to be careful because you may override the form again later on your theme... In this case look for the very last hook and apply changes there.