Getting rid of password_confirm labels in module In a module, the following generates unwanted labels for 'Password' and 'Password confirm':

$form['password'] = array(
  '#type' =&gt; 'password_confirm',
  '#maxlength' =&gt; 20, 
  '#size' =&gt; 10,
);


It produces the following HTML:

&lt;div class="form-item form-type-password form-item-password-pass1"&gt;
  &lt;label for="edit-password-pass1"&gt;Password &lt;/label&gt;
  &lt;input class="password-field form-text" type="password" id="edit-password-pass1" name="password[pass1]" size="10" maxlength="128" /&gt;
&lt;/div&gt;
&lt;div class="form-item form-type-password form-item-password-pass2"&gt;
  &lt;label for="edit-password-pass2"&gt;Confirm password &lt;/label&gt;
  &lt;input class="password-confirm form-text" type="password" id="edit-password-pass2" name="password[pass2]" size="10" maxlength="128" /&gt;
&lt;/div&gt;


The object is to get rid of the text labels and replace them with images.  I have tried toggling '#title', '#title_display' and '#label_display' but nothing works.

Any ideas?
I agree with @Clive that it is not a good idea to remove those labels, but there is a way to make them invisible, without to remove them. Drupal 7 has a CSS class for that purpose: element-invisible.

The code I would write is similar to the following one.

function mymodule_form($form, &amp;$form_state) {
  $form['password'] = array(
    '#type' =&gt; 'password_confirm',
    '#maxlength' =&gt; 20, 
    '#size' =&gt; 10,
    '#process' =&gt; array('form_process_password_confirm', 'code_testing_process_password', 'user_form_process_password_confirm'),
  );

  return $form;
}

function mymodule_process_password($element) {
  $element['pass1']['#title'] =  '&lt;span class="element-invisible"&gt;' . t('Password') . '&lt;/span&gt;';
  $element['pass2']['#title'] =  '&lt;span class="element-invisible"&gt;' . t('Confirm password') . '&lt;/span&gt;';

  return $element;
}


The process functions I am using are the same used from the "password_confirm" form field, except the second one, which is my custom process function I use to make the label invisible.

You could also replace the reference to form_process_password_confirm() if you want to radically change the output for the form fields. The last process function I am using is the one that adds the JavaScript code which checks when the password entered in the two form fields is the same, among other things.