[development] Disabling E-mail field in User Account > Edit

Toufeeq Hussain toufeeqh at gmail.com
Sun Dec 11 13:49:41 UTC 2005


Hi,

I'm trying to disable the e-mail and user_name filed in the User
Account Edit page.
These details will be populated from LDAP so an user should not be
able to edit them.

I've poked around and found the code which handles this in user.module.
Now I need to disable this control.

<Code>
$group .= form_textfield(t('E-mail address'), 'mail', $edit['mail'],
  30, 55, t('Insert 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.'),
NULL, TRUE);
</Code>

looking up documentation for the form_textfield control
(http://drupaldocs.org/api/head/function/form_textfield) tells me that
I need to pass HTML attributes to this in the form of an associative
array.

Now to disable it I need to pass the attribute 'readonly' so I created
an associative array as such $html_params = array("RO" => "readonly")
and passed it to form_textfield as such:

<Code>
$group .= form_textfield(t('E-mail address'), 'mail', $edit['mail'],
  30, 55, t('Insert 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.'),
*$html_params*, TRUE);
</Code>

(The *'s highlight the change)

However this does not seem to be working,E-mail field is still editable.
What am I missing ?

Please help.
-Toufeeq
--
blog @ http://toufeeq.blogspot.com


More information about the development mailing list