Expand my Community achievements bar.

SOLVED

Naming Elements Dynamically

Avatar

Level 2

Hi Guys,

Does anyone know if it is possible to name adaptive form elements dynamically? For example if I have a textbox and a radio button, is it possible to code this logic into the textbox or radio button

if radiobutton.value == 1, then textbox element name = first

Thanks guys,

Afam

1 Accepted Solution

Avatar

Correct answer by
Level 3

This can be achieved by css, If you see the Adaptive Form created using 'survey' template, it has each question prefixed by an incremental number, if one question is hidden, the numbers readjust. Also this can be seen in Adaptive Form created using 'simple enrollment' template, each panel title is prefixed with a number, if a panel is hidden (its visibility expression computes to false) the prefixed number readjusts according to series. Following is the css code governing these behavior:

//survey styles.less snippet .panel { counter-reset:section; } .panel .guidefield .guideFieldLabel:before { counter-increment: section; content: counter(section) ". "; padding-right: 5px; font-size: 17px; }
// simple enrollment styles.less snippet .wizard-navigators { text-transform: uppercase; > li { border: none; outline: none; &:before { border-width: 0px; margin-right: 10px; content: counter(item); .rounded-corners(5px); padding: 3px 8px; color: #ffffff; font-size: @tabs-font-size; background-color: @wizard-tabs-font-color; } }

View solution in original post

5 Replies

Avatar

Employee

No, this is not supported.

What is the use case? May be I can help you with some alternate suggestion.

Avatar

Level 2

Hi Deepak,

Slightly different request. Do you know any good links you can recommend to me on how to pre populate AEM adaptive forms using data from a web service?

Thanks mate.

Afam

Avatar

Level 2

Thanks Deepak

Basically I have a radio button which dynamically hides/displays entire sections of an adaptive form.

The issue is each section is number i.e. 1. section 1, 2. section 2, 3. section 3

I was hoping that when a section gets hidden, for instance 2. section 2, I can rename 3. section 3 as 2. section 2

Kind Regards,

Afam

Avatar

Correct answer by
Level 3

This can be achieved by css, If you see the Adaptive Form created using 'survey' template, it has each question prefixed by an incremental number, if one question is hidden, the numbers readjust. Also this can be seen in Adaptive Form created using 'simple enrollment' template, each panel title is prefixed with a number, if a panel is hidden (its visibility expression computes to false) the prefixed number readjusts according to series. Following is the css code governing these behavior:

//survey styles.less snippet .panel { counter-reset:section; } .panel .guidefield .guideFieldLabel:before { counter-increment: section; content: counter(section) ". "; padding-right: 5px; font-size: 17px; }
// simple enrollment styles.less snippet .wizard-navigators { text-transform: uppercase; > li { border: none; outline: none; &:before { border-width: 0px; margin-right: 10px; content: counter(item); .rounded-corners(5px); padding: 3px 8px; color: #ffffff; font-size: @tabs-font-size; background-color: @wizard-tabs-font-color; } }

Avatar

Level 2

Thanks Sakshi

Much appreciated.

Afam