Add dropdown list & checkbox list to registration form -

Posted by laura@refactoredmedia.com on 13-Feb-2020 20:46

I added some custom fields to the user profile. One of them is a dropdown list and the other is a multi select (checkboxes) which I added values to for the "Choices" in those fields. I would like to show these values in the registration form view. How do I do this?

All Replies

Posted by Junior Dominguez on 13-Feb-2020 21:13

Hi Laura,

Please take a look to this KB article in order to achieve your goal:

knowledgebase.progress.com/.../how-to-work-with-basic-profile-custom-fields-in-mvc-profile-and-registration-widgets

Best regards

Posted by laura@refactoredmedia.com on 13-Feb-2020 21:20

Hi Junior. Sadly, that article only shows how to add a custom text box field. I need to add a dropdown list and checkbox list that has the options filled from the values I entered in the custom field from the admin interface.

Posted by laura@refactoredmedia.com on 13-Feb-2020 21:20

Hi Junior. Sadly, that article only shows how to add a custom text box field. I need to add a dropdown list and checkbox list that has the options filled from the values I entered in the custom field from the admin interface.

Posted by laura@refactoredmedia.com on 26-Feb-2020 16:33

The code sample below is the way to set the values. For persisting the values in the database, it is needed to save the changes by using the UserProfileManager:

UserProfileManager profileManager = UserProfileManager.GetManager();

.......

profile.SetValue("Checkboxes", new string[] { "Option2" } );

......

profileManager.SaveChanges();

However, it is a good practice to execute the logic in the controller and keep the view only for displaying the value.

Here is a code sample to display the custom field values in the view after they have been set:

@foreach (var choice in Model.Item.Fields.Choices) //Choices is a custom ChoiceField added to a content type

{

<span>@choice.Text.ToString()</span> :

<span>@choice.PersistedValue.ToString()</span>

}

For more details, please check this KB article - knowledgebase.progress.com/.../mvc-how-to-display-custom-choicefield-s-selected-choices-using-razor

This thread is closed