Developer forum

Forum » CMS - Standard features » Creating users from front-end: Possible to modify fields?

Creating users from front-end: Possible to modify fields?

Joakim Tønnesen
Reply

Hello,

 

I have a "register new user" page. I'm using the Extranet/Intranet (Extended) module to get the input fields. I attached the template used to get the fields to this post. 

1: Can I modify or add new input fields somehow? In this case I need a field called "Office", while the "Phone"-field is not really necessary. I've tried adding custom fields here: Management Center -> User Management, but I did not figure out how to display the field in the form template.

When I edit a user in the back-end, there is an area called work, under which certain work-related data is gathered. Is there a way to add new fields to this area?

 

2: How do I handle required fields? Ideally I want certain fields to be required to fill out in order for a user to submit the form.

 

 

 

Thanks in advance

best regards

Joakim

 

 

 

 

 

  


Replies

 
Mikkel Ricky
Reply
This post has been marked as an answer

1. Input controls for custom user fields are currently only available in the loop UserManagement:User.CustomFields, i.e. you have to write something like

<!--@LoopStart(UserManagement:User.CustomFields)-->
    <!--@If(CustomField.SystemName=="AccessUser_Office")-->
    <b><!--@CustomField.Name--></b>
    <br/>
    <!--@CustomField.Control-->
    <br /><br />
    <!--@EndIf-->
<!--@LoopEnd(UserManagement:User.CustomFields)-->

to render the custom fields.

I've created a product backlog item for exposing custom fields just like built-in field so it will be possible to write <!--@UserManagement:User.CustomField.Office.Input--> in the template

2. The module only validates username, password and email as required fields, and this validation is performed on the server. Your best option right now for validating other fields is to add some JavaScript validation. A very simple solution for requiring all text fields to be non-empty is something like this

<script>window.addEventListener('load', function() {
     var form = document.querySelector('form[name=UserManagementEditForm]');
     if (form) {
         form.addEventListener('submit', function(event) {
             var i, field, fields = form.querySelectorAll('input');
             for (i = 0; field = fields[i]; i++) {
                 if (field.type == 'text' && !field.value) {
                     alert('Missing value in field '+field.name);
                     event.preventDefault();
                     break;
                 }
             }
         });
     }
})</script>

We will look into improving the extranet module with custom validation rules to make it possible to define which fields are required. 

Best regards,
Mikkel

 

 

 

Votes for this answer: 1
 
Joakim Tønnesen
Reply

Thank you, Mikkel!

 

You must be logged in to post in the forum