-1

I have to hide the fields password and verify password from UI screen and assign a default password xyz for the new users created. Please suggest how I can do that in the below snippet:

<div class="field-row">
  <span class="crud-label">${msg("bel.password")}:&nbsp;*</span>
</div>
<div class="field-row" type="hidden">
  <input class="crud-input" id="${el}-create-password" type="password" maxlength="100" />
</div>
<div class="field-row">
  <span class="crud-label">${msg("label.rifypassword")}:&nbsp;*</span>
</div>
<div class="field-row" type="hidden">
  <input class="crud-input" id="${el}-create-verifypassword" type="password" maxlength="100" />
</div>
Fred
  • 2,402
  • 4
  • 31
  • 58
APM
  • 29
  • 1
  • 9
  • Adding the `hidden`-class can be done on the `field-row`-class, but for the default password (a horrible idea, btw), this won't do anything, because there is some sort of processing of these values somewhere - there is no inputs in the code you show us, so there is no way to add a value anywhere... And at least the default password should be done server-side, so it's not visible to anyone visiting the page. – junkfoodjunkie Nov 17 '16 at 10:58
  • Can a javascript file be of any help?? – APM Nov 17 '16 at 11:02
  • form.addValidation(parent.id + "-create-password", Alfresco.forms.validation.mandatory, null, "keyup"); form.addValidation(parent.id + "-create-password", Alfresco.forms.validation.length, { min: parent.options.minPasswordLength, max: 100, crop: true, ignoreEmpty: true }, "change", parent._msg("Alfresco.forms.validation.length.message.min", parent.options.minPasswordLength)); – APM Nov 17 '16 at 11:03
  • Found this in the validation part – APM Nov 17 '16 at 11:04
  • I agree with @junkfoodjunkie, the default password should really be set on the server's side. CSS and Javascript is all "client-side", so anyone will be able to go into your source and see the default values. However, I added an answer as you requested. – Fred Nov 18 '16 at 05:15

2 Answers2

0

Seeing that no one helped you yet, let me help you here :).

You can set a default value on an input field with the "value" property.

Use this HTML:

<div class="field-row">
  <span class="crud-label">${msg("bel.password")}:&nbsp;*</span>
</div>
<div class="field-row hidden" type="hidden">
  <input class="crud-input" id="${el}-create-password" value="defaultPassword" type="password" maxlength="100" />
</div>
<div class="field-row">
  <span class="crud-label">${msg("label.rifypassword")}:&nbsp;*</span>
</div>
<div class="field-row hidden" type="hidden">
  <input class="crud-input" id="${el}-create-verifypassword" value="defaultPassword" type="password" maxlength="100" />
</div>

This will result in your default password values to be "defaultPassword".

Now, to hide these fields, you can use CSS:

.hidden {
    display: none;
}

Note that in the HTML I added extra class names. You add extra class names by just adding more to the class="", seperated by a space.

If you use jQuery or something, you can also set the display to none with:

$(".hidden").css("display", "none");

Hope this helped you!

Fred
  • 2,402
  • 4
  • 31
  • 58
  • What do you mean it's not working? for the passwords you specify a "value" attribute and set the default password in there. to hide them, you give the textboxes "display:hidden;" CSS. This should work. – Fred Nov 18 '16 at 08:49
  • Check this fiddle. I hid the second password field, but it still have it's default value. https://jsfiddle.net/FredM7/8eq14cuw/ – Fred Nov 18 '16 at 08:54
0

If you hide the password & confirm password controls in alfresco share, the form will not be sent to the server. So disable them and set the default values for it.

Hope the below code helps you.

 <div class="field-row">
                  <input class="crud-input" id="${el}-create-password" type="password" maxlength="100" value="admin"  disabled="disabled"/>
               </div>
               <div class="field-row">
                  <span class="crud-label">${msg("label.verifypassword")}:&nbsp;*</span>
               </div>
               <div class="field-row">
                  <input class="crud-input" id="${el}-create-verifypassword" type="password" maxlength="100" value="admin"  disabled="disabled"/>
               </div>