I have assigned class names to both user name & password text fields in user login block separately like this and it's working.
function mymodule_form_alter(&$form, &$form_state, $form_id, $element) {
if ( TRUE === in_array( $form_id, array( 'user_login', 'user_login_block') ) ) {
$form['name']['#attributes']['class'] = array('mgnB10', 'fntXL', 'drkFg1');
$form['pass']['#attributes']['class'] = array('fntXL', 'drkFg1');
}
}
I want to include these fields inside a single '' and assign class name for design purpose, like this.
<div class="class-name">
username field
password field
</div>
I am using the following code but I didn't get the expected output.
function mymodule_form_alter(&$form, &$form_state, $form_id, $element) {
if ( TRUE === in_array( $form_id, array( 'user_login', 'user_login_block') ) ) {
$form['user_login']['#attributes']['class'] = array('#prefix' => 'myclass');
$form['name']['#attributes']['class'] = array('mgnB10', 'fntXL', 'drkFg1');
$form['pass']['#attributes']['class'] = array('fntXL', 'drkFg1');
$form['user_login'] = array('#suffix' => '</div>');
}
}