When default_value for password field is set it does not show on page. This is because in theme_password html property for value is not set.

I attached a patch that fixes this.

CommentFileSizeAuthor
form.inc.patch_3.txt928 bytesRok Žlender

Comments

Rok Žlender’s picture

After talking with some people on irc I came to realize that this might be a security feature. If this is so it should be corrected on http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference... to show that password field cannot have default value.

moshe weitzman’s picture

Status: Needs review » Active

this is a browser limitation, not drupal. and yes, is a security consideration. docs would be useful.

chx’s picture

Project: Drupal core » Documentation
Version: x.y.z »
Component: forms system » Developer Guide
ronaldmulero’s picture

Status: Active » Closed (fixed)

old issue

f0nZ’s picture

Component: Developer Guide » Correction/Clarification

You can still define username/password with javascript (At least with D5).
Here's some javascript to clear username/password default value onFocus :

function init() {
 var inputs = document.getElementsByTagName('input');
 for(var i=0; i < inputs.length; i++) {
  if (inputs[i].type == 'text') {
	  if(inputs[i].id == "edit-pass"){inputs[i].defaultValue = "Password";}
	  if(inputs[i].id == "edit-name"){inputs[i].defaultValue = "Username";}
   inputs[i].setAttribute('rel',inputs[i].defaultValue);
   inputs[i].setAttribute('reltype',inputs[i].type);
   inputs[i].onfocus = function() {
    if (this.value == this.getAttribute('rel')) {
     if (this.value == 'Mot de passe') {
		 this.type = 'password';
	 }
		this.value = '';

    } else {
     return false;
    }
   }
   inputs[i].onblur = function() {
    if(this.value=='') { 
	 this.type = 'textfield';
     this.value = this.getAttribute('rel');
    } else {
     return false;
    }
   }
   inputs[i].ondblclick = function() {
	this.value = this.getAttribute('rel');
   }
  }
 }
}
 
if(document.childNodes) {
 window.onload = init;
}

Don't forget to import your javascript file with..:

drupal_add_js(drupal_get_path('theme', 'yourtheme') .'/inputs.js', 'theme');

.. in template.php

mattcasey’s picture

f0nZ, I'm not sure why you set the input to 'textfield' during onBlur(), but on D6 this causes the password to be revealed after clicking away. The code still works when I just remove the line towards the bottom:

	 this.type = 'textfield';