In the modules/user/user.module on line 1448 there is not size parameter for the account-name textfield. Because of this the textfield is a whopping 80 characters long ! While the maximum size for the account-name is set to 60 characters.

This makes no sense and in fact in certain themes (like the Burnt theme) it causes problems because the table is so wide things become invisible and useless (like the theme selection which has a checkbox at the extreme right which is underneath the right pane).

The same problem with the the account-email textfield on line 1456. This textfield is also 80 characters in size while the max email size is set to 65. Both require a:

'#size' => 25,

to make it acceptable.

I added a screenshot to make it more clear.

Comments

brianV’s picture

Version: 6.9 » 7.x-dev
Issue tags: +Novice

This would be a good Novice task.

shawn dearmond’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

Here's a patch.

I matched the size defined in user.install. That means 60 for name and 64 for mail.

catch’s picture

Issue tags: +Needs screenshots

Could you post a before/after screenshot for this?

shawn dearmond’s picture

StatusFileSize
new209.78 KB
new209.79 KB

Screenshots attached.

dale42’s picture

In this instance basing the email form field length on the actual field length probably isn't a good idea. Per #470306: User email column too short (only 64 chars, should be 255), there is talk of expanding the length of the email field in the database.

In addition to being used on user/%/edit, I believe this form is also used on admin/user/user/create.

I checked with Firebug and see that size=60 is currently being used for the Username and E-Mail form fields on HEAD. Looking at the code, I see the size isn't explicitly set in the form definition, so this must be a form API default?:

<?php
function user_edit_form(&$form_state, $uid, $edit, $register = FALSE) {
  [...]
  if ($register || ($GLOBALS['user']->uid == $uid && user_access('change own username')) || $admin) {
    $form['account']['name'] = array('#type' => 'textfield',
      '#title' => t('Username'),
      '#default_value' => $edit['name'],
      '#maxlength' => USERNAME_MAX_LENGTH,
      '#description' => t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, apostrophes, and underscores.'),
      '#required' => TRUE,
      '#attributes' => array('class' => 'username'),
    );
  }
  $form['account']['mail'] = array('#type' => 'textfield',
    '#title' => t('E-mail address'),
    '#default_value' => $edit['mail'],
    '#maxlength' => EMAIL_MAX_LENGTH,
    '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
    '#required' => TRUE,
  );
  [...]
}
?>

A value of 60 strikes me as a reasonable size for both fields, and I think the form looks better if they are an equal size. Given a possible change in email db length, adding an additional 4 characters to the form's email field doesn't seem worth it.

Given the current default value appears to be 60, I'm not sure any action is required. If it's worth giving the form field sizes an explicit value, I vote both be set to 60.

Also, the original bug report was as much a bug report for a specific theme as it was for user module behaviour. Estimating sizes based on the screen shots provided, I'd say the reported problem still won't be solved by changing form field lengths to 60. A bug report should probably be filed on the theme in question.

dale42’s picture

In hindsight, may have been more concise to state as follows:

In Drupal 7 the username and email form fields are currently size=60 (set implicitly)
What is a reasonable length for these fields, size=60, size=25 as suggested in submission, or something in between?
If size=60 is the answer, should this be explicitly set? If answer is no, then no further action is required.

Is there any way to gather username and email length stats from D.O. to get an idea of typical username and email lengths? That might help determine the answer to ideal field length. Or is that overkill?

shawn dearmond’s picture

That's reasonable. Any other comments before we mark this "Won't Fix"?

Status: Needs review » Needs work

The last submitted patch failed testing.

Amazon’s picture

Status: Needs work » Needs review

Bad bot.

andypost’s picture

bot was failed

arianek’s picture

Status: Needs review » Closed (won't fix)

conferred with webchick, and going to mark this as "won't fix" it does not appear to be necessary, or much of an improvement aesthetically - if it's really a problem, it can be overridden in the theme. it's arbitrary to shrink down long fields to only be able to show 25 chars rather than the full amt of characters allowed - and in this case, it looks like it's largely because of the theme used in the example that it looks so drastic.