How to get form field caption with API

hadi tag asked on March 9, 2016 11:56

hi, i am using kentico 8.1 and i create a custom webpart whose task is to display the information in a form

I am showing the values in the form fields with : item.GetStringValue(item.ColumnNames[i], "")

But I do not know how to display the field caption

please help me

Correct Answer

Anton Grekhovodov answered on March 9, 2016 19:07

Hi Hagi,

You can use this code to get names of all fields:

var formObject = BizFormInfoProvider.GetBizFormInfo("FormName", SiteContext.CurrentSiteID);
var visibleFields = formObject.Form.GetFields(true, false);
foreach (FormFieldInfo field in visibleFields)
{
   var disyplayName = field.GetDisplayName(MacroResolver.GetInstance());
   //...
}
1 votesVote for this answer Unmark Correct answer

Recent Answers


Joshua Adams answered on March 9, 2016 15:47

Does the webpart have to do anything besides show information? If not, may want to look at having an alternate form and changing everything to labels. It can be done through code, and I have a snippet somewhere that does that, but it may make more sense to have this as an alternate form depending on your needs. If thats not an option, I can find the snippet and post it here.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.