Get custom control field caption

Brittany Sanford asked on August 27, 2020 18:03

Hi!

Is there a way to access field properties like the Field Caption from the custom control code? I do not have a static name to put in, because the fields will not always be named the same thing, and this is for multiple forms.

Thanks!

Recent Answers


Dmitry Bastron answered on August 28, 2020 10:31

Hi Brittany,

Are you talking about MVC Form Builder custom form controls or custom Portal Engine Form Controls? What version of Kentico do you use and is it Portal Engine or MVC?

0 votesVote for this answer Mark as a Correct answer

Brittany Sanford answered on August 28, 2020 19:08

Hi Dmitry,

I'm running v11.0.17 Portal Engine. What I'm trying to do is set a custom aria-label field of my control to the "field caption" of the field it's being used on in the form. I have everything put in for the aria-label property of my custom control and the code to set up the aria-label attribute, but can't figure out how to pull in the field caption value.

Thanks for your help, Brittany

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 30, 2020 00:13

Dear Brittany, inside your form control code (inherited from FormEngineUserControl) you can access it like this:

var caption = this.FieldInfo.Caption;
0 votesVote for this answer Mark as a Correct answer

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