I'm using version 7 alpha 3 and a custom theme based on seven.

What I want to do is remove the descriptions on the user/login page text fields.
For example, under the password field label it says:
Enter the password that accompanies your username.

I know a couple ways to do it:

  • css: color text same as background (yuck)
  • change the markup based on the name of the text field:
    code from form.inc function theme_form_element($variables)
    if (!empty($element['#description'])) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; }
    change in my template.php mytheme_form_element($variables) to
    if ((!empty($element['#description'])) && ($element[#title] != "Password" ||  $element[#title] != "Username")) { $output .= ' <div class="description">' . $element['#description'] . "</div>\n"; }

But these aren't sound solutions (e.g., maybe I want other Username fields elsewhere to have descriptions).
What I really want is an empty $element['#description'] for the user/login form text fields.

I know where these are defined.
It's in user.module
function user_login($form, &$form_state)
on lines 1816 and 1819 (again, I'm using Drupal 7 alpha 3).

$form['name']['#description'] = t('Enter your @s username.', array('@s' => variable_get('site_name', 'Drupal')));
  $form['pass'] = array('#type' => 'password',
    '#title' => t('Password'),
    '#description' => t('Enter the password that accompanies your username.'),

It's more the process than the result that interests me as this is my first Drupal project,
but I don't know how to remove those descriptions for just the user/login page form without
copying the entire module to my sites/all/modules and modifying it.

Thanks,
nJ

Comments

CSS is one way as you mentioned. Another way is to write a small module that uses hook_form_FORM_ID_alter. You can try using this to set those array values to empty.

Excellent.
That was exactly what I needed for two reasons:
1. It answered the question.
2. It inspired my next quest to learn how to write a basic module.

Here's what I did (in case someone else needs to know):

  1. create directory -- sites/all/modules/alterlogin
  2. in that directory make files alterlogin.module and alterlogin.info
  3. alterlogin.module
    <?php
    // remove description from user login form text fields
    function alterlogin_form_user_login_alter(&$form, &$form_state) {
     
    $form['name']['#description'] = t('');
     
    $form['pass'] = array('#type'  => 'password',
                           
    '#title' => t('Password'),
                           
    '#description' => t(''),
                           
    '#required' => TRUE,
                           );
    }
    ?>

    alterlogin.info
    name = alterlogin
    description = Alter the user login form
    core = 7.x
    files[] = alterlogin.module

  4. clear Drupal cache and enable the new module in admin/modules

Worked perfectly.
Thanks!

4201 error: signature invalid: user_signature() parenthesis cannot be passed as argument

Thanks in two seconds learned how to make a basic module plus this can be used like a "Custom Module" and we can include ALL our custom settings inside one module and with options to choose it a mouse click which functions we want...

I removed "labels", "descriptions" and used "placeholder" (with "Username" and "Password" in the input for login).
I also removed "title", "button" and included "Type and press Enter..." as a "placeholder" in the search box.

Nice idea and thanks for the input mate.

Is it possible to simply edit the user module to eliminate the "Enter the password that accompanies your username." ?

Shepherd348