Project
I wanted to override the username field to say "Drupal.org username".
Modules
- https://www.drupal.org/project/change_labels
- https://www.drupal.org/project/better_field_descriptions
- https://www.drupal.org/project/field_label_override
- https://www.drupal.org/project/node_form_overrides
- https://www.drupal.org/project/field_label
- https://www.drupal.org/project/entity_form_field_label
Code
The modules didn't work on the field, so this is what I ended up using:
function drupal_contrib_custom_form_user_register_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
if (!empty($form['drupal_org_profiles'])) {
$form['account']['name']['#title'] = t('drupal.org username');
unset($form['drupal_org_profiles']);
}
if (!empty($form['organization_profiles'])) {
$form['account']['name']['#title'] = t('Username (drupal.org username if you have one)');
unset($form['drupal_org_profiles']);
}
}