Project
I wanted to override the username field to say "Drupal.org username".
Modules
- View Change labels on Drupal.orgChange labels
- View Better Field Descriptions on Drupal.orgBetter Field Descriptions
- View Field Label Override on Drupal.orgField Label Override
- View Node Form Overrides on Drupal.orgNode Form Overrides
- View Field Label on Drupal.orgField Label
- View Entity Form/Display Field Label on Drupal.orgEntity Form/Display 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']);
}
}