On the user login form, I am trying to take the "help text" and make it an input placeholder (so that the help text shows up in the input and disappears when the user enters their username and password).
Here's my code:
function mymodule_form_user_login_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$form['name']['#placeholder'] = $form['name']['#description'];
$form['pass']['#placeholder'] = $form['pass']['#description'];
// $form['name']['#description']['#access'] = FALSE;
// $form['pass']['#description']['#access'] = FALSE;
}
This adds the placeholder correctly but it doesn't hide the help text, so the text appears twice (in the input and below the input). In Drupal 7, I just set access to false, but in Drupal 8 the description is an object so I don't know what to do.
unset($form['pass']['#description']);
will work. Or a simple -$form['pass']['#description'] = '';
Don't have an instance of D8 at hand to test.