Skip to main content
June 21, 2023
Question

Duplicating Section layout on button click

  • June 21, 2023
  • 9 replies
  • 0 views

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

    9 replies

    June 21, 2023

    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"
        )
      }
    )

    June 21, 2023

    Thank you Very much

    harshitb6843
    June 21, 2023

    Please consider accepting the answer so if any one else is facing the same issue, they can look at the solution that was working.