I'm trying to customize user login form in /user/login
page and I want to use a hook_form_alter
function to add some awesome style and placeholder to each of user login form fields and remove or hide:
"Enter your admin username" and "Enter the password that accompanies your username" description expressions under each of theme.
To resolve this issue I added something like below code to my ThemeName.theme:
function ThemeName_form_alter(&$form, $form_state, $form_id) {
if ( $form['#form_id'] == 'user_login_form' ) {
$form['actions']['submit']['#attributes']['class'][] = 'button glow button-primary expanded';
$form['keys']['#attributes']['placeholder']['name'] = t('User name');
$form['keys']['#attributes']['placeholder']['password'] = t('Password');
}
}
I try out many different ways but I can't get any result.
in finally I want to achieve something like below image:
I read this pages but seems none work in Drupal 8:
How to modify the fields of user registration form and user login form?
Modifying the default user registration page
Customize user login block
user-login-form
should beuser_login_form
in your function..user-login-form .description { display: none; }
form_alter()
stuff