Aidy's statement is 100% correct with the Sitecore version you are using but with the Sitecore version 9, the Password field is changed a little bit and works as per your requirement and not expose the value event via Raw values. If you want the same functionality in Sitecore version 8.1u2 then you need to customize the existing password field or need to create a new password field. I am sharing updates for existing password field here-
- Create a new class field, give it the same name as the field name. i.e Password
Add the below code -
public class Password : Sitecore.Shell.Applications.ContentEditor.Text
{
public Password()
{
this.Password = true;
this.Activation = true;
}
protected override bool LoadPostData(string value)
{
value = StringUtil.GetString(value);
if (this.Value == value || this.Value.Replace("\n", string.Empty) == value || this.Value.Replace(Environment.NewLine, string.Empty) == value)
return false;
this.Value = value;
this.SetModified();
return true;
}
protected override void SetModified()
{
base.SetModified();
if (!this.TrackModified)
return;
Sitecore.Context.ClientPage.Modified = true;
}
protected override void DoRender(HtmlTextWriter output)
{
this.Attributes["placeholder"] = Translate.Text(this.Placeholder);
this.SetWidthAndHeightStyle();
string str = this.TransformPasswordText();
output.Write("<input" + this.ControlAttributes + str + ">");
this.RenderChildren(output);
}
private string TransformPasswordText()
{
string str = string.Empty;
if (this.Password)
{
str = " type=\"password\"";
try
{
this.Attributes["value"] = new StringBuilder().Insert(0, "•", this.Attributes["value"] == null ? 0 : this.Attributes["value"].Length).ToString();
}
catch
{
Log.Warn("Could not resolve password length.", (object)this);
}
}
if (!string.IsNullOrEmpty(str))
return str;
return !this.Hidden ? "" : " type=\"hidden\"";
}
}
After that next step is to add a patch config for our custom course, where you need to pass namespace where your Password class is located, assembly name and a prefix to identify the control source -
<configuration xmlns:x="https://www.sitecore.com/xmlconfig/">
<sitecore>
<controlSources>
<source mode="on" namespace="yournamespace" assembly="yourassemblyname" prefix="customcontent" />
</controlSources>
</sitecore>
</configuration>
The next step is to update the Password field in the core database. Navigate to password field - /sitecore/system/Field types/Simple Types/Password
and update the control
field with the prefix and class name (prefix:classname), in our case it will be customcontent:password
-
In the above code, TransformPasswordText
function is taking care for transforming the password text into ***.
I think this will resolve your problem. If you want to create a separate field then you can simply duplicate the existing password field and perform the same steps.