-1

I have altered login form, removed fields description like this (mytheme.theme):

function mytheme_form_user_login_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {

  if (isset($form['name']) && $form['name']['#type'] == 'textfield') {
    unset($form['name']['#title'], $form['name']['#description']);
  }

  if (isset($form['pass']) && $form['name']['#type'] == 'textfield') {
    unset($form['pass']['#title'], $form['pass']['#description']);
  }

}

I want to go further and , remove Login block title and local-tasks (Login, Register, Reset password). How to do this? I could just CSS display none it, but thats sounds not very natural...

0

You can go ahead with the hook_form_alter().

function your_custom_module_name_form_alter(&$form, $form_state, $form_id) {
switch ($form_id) {
case 'user_register_form':
// print the $form and you can see the entire structure of the login form. 
//You can then unset or overwrite the elements.
break;
case 'user_login_block':
....
break;
case 'user_login':
....
break;
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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