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"; }
- code from form.inc
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
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
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):
Worked perfectly.
Thanks!
It's that simple making a module huh?
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.
Thanks For Your Post.Its very
Thanks For Your Post.Its very Helpful For me.....
Is it possible to simply edit
Is it possible to simply edit the user module to eliminate the "Enter the password that accompanies your username." ?
Easy with yourtheme_form_alter()
All this can also be done from the front.
Try this:
Thanks For Your Post.Its very
Thanks For Your Post.Its very Helpful For me.....
alterlogin not working for me
alterlogin.module and alterlogin.info (in the form of a module) are not working for me. Simply no effect; neither any error nor the descriptions are going. Even when I removed 'Enter the password accompanied...etc..' from user.module, nothing is happening. I tried clearing the cache of my Drupal installation as well as my browser (Chrome). Any suggestions? (for removing the descriptions in username and password fields).
Your post is from a long time
Your post is from a long time ago but if it can help others :
For drupal 8 :
Great attempt
This seems all perfect. I got the missing features for my login form.
Simple way is to create a custom module and alter the form
Create a test custom module to hide the content using hook_form_alter. Write following code inside the test module and refresh the page. The description text will not be visible.
function pfe_test_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'user_register_form' || $form_id == 'user_profile_form') {
$form['account']['name']['#description'] = t('');
$form['account']['mail']['#description'] = t('');
}
}