Skip to main content
Best answer by tim.clarke

Here's a basic example, you should be able to swap in your type! values and configure your components

a!localVariables(
  local!someVar,
  {
    a!forEach(
      items: local!someVar,
      expression: a!sectionLayout(
        label: "Section: " & fv!index,
        divider: "ABOVE",
        contents: {
          a!textField(
            label: "Name",
            value: fv!item.name,
            saveInto: fv!item.name
          ),
          a!dateField(
            label: "DoB",
            value: fv!item.dob,
            saveInto: fv!item.dob
          )
        }
      )
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          icon: "plus",
          label: "Add Row",
          value: a!map(name: null, dob: null),
          saveInto: a!save(
            target: local!someVar,
            value: append(local!someVar, save!value)
          )
        )
      }
    )
  }
)

3 replies

kishorej1999
August 20, 2024

Hii [mention:0591d80bf3a5406ebeb3855605fe90c0:e9ed411860ed4f2ba0265705b8793d05] , can you please explain more about your use case.

miguelm0020
August 20, 2024

Hello, I'm not sure if this is what you are looking for but I'll give it a try.

I imagine you are working with an array of something, like a CDT or Record Type.

What I would do is to have that array as rule input / local variable and then do a forEach() over it. Inside the forEach() you would put whatever fields you want (even as a section as you mentioned).

To add more instances of that section, you'd create a button that would append an empty value (CDT or Record Type) to your variable. This way the fields/section is going to be repeated:

(...)saveInto: a!save(
    ri!variable,
    append(
        ri!variable,
        type!CDT()
    )
)

tim.clarke
August 20, 2024

Here's a basic example, you should be able to swap in your type! values and configure your components

a!localVariables(
  local!someVar,
  {
    a!forEach(
      items: local!someVar,
      expression: a!sectionLayout(
        label: "Section: " & fv!index,
        divider: "ABOVE",
        contents: {
          a!textField(
            label: "Name",
            value: fv!item.name,
            saveInto: fv!item.name
          ),
          a!dateField(
            label: "DoB",
            value: fv!item.dob,
            saveInto: fv!item.dob
          )
        }
      )
    ),
    a!buttonArrayLayout(
      buttons: {
        a!buttonWidget(
          icon: "plus",
          label: "Add Row",
          value: a!map(name: null, dob: null),
          saveInto: a!save(
            target: local!someVar,
            value: append(local!someVar, save!value)
          )
        )
      }
    )
  }
)