Duplicating Section layout on button click

Certified Senior Developer

Hi, I have a requirement where I need to duplicate a particular section on clicking add button. In the section I have some text fields and clicking on the "Add" button the text fields should get duplicated where I have to enter new values in the field. Is it achievable? or is there any other method where I can duplicate the fields on clicking the button ?Please let me know

Thanks

  Discussion posts and replies are publicly visible

Parents
  • You can achieve this with the help of a!forEach() 

    Example: 

    a!localVariables(
      local!count: 1,
      {
        a!forEach(
          enumerate(local!count),
          a!sectionLayout(
            label: "Section",
            contents: {
              a!textField(
                label: "Text",
                labelPosition: "ABOVE",
                saveInto: {},
                refreshAfter: "UNFOCUS",
                validations: {}
              )
            }
          )
        ),
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "Add Section",
              style: "NORMAL",
              saveInto: a!save(local!count, local!count + 1)
            )
          },
          align: "START"
        )
      }
    )

Reply
  • You can achieve this with the help of a!forEach() 

    Example: 

    a!localVariables(
      local!count: 1,
      {
        a!forEach(
          enumerate(local!count),
          a!sectionLayout(
            label: "Section",
            contents: {
              a!textField(
                label: "Text",
                labelPosition: "ABOVE",
                saveInto: {},
                refreshAfter: "UNFOCUS",
                validations: {}
              )
            }
          )
        ),
        a!buttonArrayLayout(
          buttons: {
            a!buttonWidget(
              label: "Add Section",
              style: "NORMAL",
              saveInto: a!save(local!count, local!count + 1)
            )
          },
          align: "START"
        )
      }
    )

Children