Try our conversational search powered by Generative AI!

Episerver forms - Field names in submission data

Vote:
 

Hello!

Iam trying to get field names for submission data in episerver forms submit events. I need to alter the value of a specified field in code that i have generated on every created form each time i submit a form before it is saved into the episerver database.

_field with ID instead of names

Any help or tips is much appriciated on how to best tackle this issue.

Best regards Jonas.C

#150880
Edited, Jul 01, 2016 9:57
Vote:
 

Generally the convention is "__field__" + the id of the block that represents the field name.

You can use the GetDataFriendlyNameInfos method on the FormDataRepository to get this information.

A FriendlyNameInfo have a ElementId that would be the "__field__#", FriendlyName and the Label.

Look at my GitHub to see how it can be used: https://github.com/alfnilsson/EpiserverForms/blob/master/Toders.Forms.Web/Business/Forms/FormReader.cs

For each field you want to display, use

FriendlyNameInfos.First(x => x.ElementId == currentfield.Key).FriendlyName

 (or .Label if you prefer).

Note: that the FriendlyNameInfo class is in the namespace internal so Episerver might change this in a future version without it being a major version even if it is a breaking change!

#150908
Jul 01, 2016 14:32
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.