1

This must be configurable somewhere, surely, but I just can't find where. I'm sure I'm doing something silly. Apologies for such a simple question.

  • 1
  • The question mentioned as a duplicate is probably not quite a duplicate. It's the way I would do this as a programmer. The only out-of-the-box solution is to create your own localization. – mradcliffe Sep 19 '18 at 13:14
  • I'll take a look at the localization option as a broader solution, thanks @mradcliffe. It's a surprise that Drupal would not have an interface for site builders to make such a change. – Mandrake... Mandrake. Sep 20 '18 at 13:40
2

Try this way by implementing hook_form_alter.


/**
 * Implements hook_form_alter().
 */
function YourCustomModuleName_form_alter(&$form, Drupal\Core\Form\FormStateInterface $form_state, $form_id){
    if ($form_id == 'user_login_form') {
        //- change label for username input
        $form['name']['#title'] = t('Your New UserName Label');
        //- change label for password input
        $form['pass']['#title'] = t('Your New Password Label');
    }
}

  • Thanks @berramou. Whilst it's workable and okay for a one-off it's not something I can offer to someone via the admin UI. It feels like Drupal core should have a non-code interface for all field labels really; this is quite an outdated approach from the point of view of a Drupal evaluator. – Mandrake... Mandrake. Sep 20 '18 at 13:43

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