How can I add a form to a page using User Profile Fields as elements and having a submit button?
-
[edited by: ibrahimk at 4:16 PM (GMT 0) on Thu, Jun 4 2020]
How can I add a form to a page using User Profile Fields as elements and having a submit button?
So, how do I create a form with select field options taken either from the User Profile Fields or directly from the SQL database as there may be too many values to enter as User Profile Field options?
A few questions to clarify what you want to do:
1. I want to save the changes back to the user profile or Profile_UserData, but some fields are dependent on the values selected in other fields so they need to be collected first before rendering other fields.
2. The select field options will range from about 10 to 1 million plus (in the case of the geographical locations - City, Region, Country combinations), so it will be impractical to enter all the fields as User Profile Field options.
It may be best to define the fields as non-selectable inputs and then create a custom widget to render the options (with dependency logic) saving back to the User API's Update method:
For widgets:
Note that profile fields can be specified using the format
_ProfileFields_FIELDNAME = 'FIELDVALUE'
I have some questions:
1. What do you mean by 'non-selectable inputs'?
2. What URL would the form post to ?
3. How would the field values be retrieved from the database? Can they be in their own custom tables?
If you could provide a bit more information about the structure of the form, that would be appreciated..
1. What do you mean by 'non-selectable inputs'?
When defining the profile fields, do not identify them as having selectable values, instead, choose "Plain Text" or "Number" as the data type. Because the selectable values will not be defined with the profile field, the profile field itself will not be able to validate the selection is valid, so the field should not be defined as selectable.
2. What URL would the form post to ?
The form itself is HTML+JavaScript+CSS. You could implement the save in JavaScript and save values to the REST endpoint
passing the values in the same format outlined above ( _ProfileFields_FIELDNAME = 'FIELDVALUE' ).
3. How would the field values be retrieved from the database? Can they be in their own custom tables?
How you populate the selectable values would then be up to you. You could define them in javascript or load them from the database (either way you're maintaining those options and how to present them). There are not APIs to support interacting with the database directly, however, so you'd need to implement your own APIs ( see https://community.telligent.com/community/11/w/developer-training/65065/widget-extensions to create a script/widget extension or https://community.telligent.com/community/11/w/developer-training/65113/exposing-data-to-external-sources to create a REST endpoint to consume via JavaScript on the client side) to either expose the options to scripts/widgets or to the client browser via REST.
If you could provide a bit more information about the structure of the form, that would be appreciated..
The form itself would be HTML+JavaScript+CSS. Generally, this would consist of a custom widget where:
Okay, thanks.