Set the default value for a password field on a custom form I have created a custom user register form. I want to set the default value for the password, and confirm the password fields.
My point is that, whenever form error occurs, the password fields get cleared. Users don't need to type the password again and again.
I think you are choosing password type field. Like below  for password and confirm password fields.

'#type' =&gt; 'password', 


Password does not support '#default_value' property. So fields getting cleared.