How to clear field value after the field is disabled

I have two fields like this, only when "Yes" is selected for "Limited" field can user input value for "Limit" field. But I found when "Limit" is disabled, the value is still there.

How can I clear value after "Limit" is disabled?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    a!localVariables(
      local!field1,
      local!field2,
      {
        a!cardLayout(
          contents: {
            a!radioButtonField(
              choiceLabels: { "Yes", "No" },
              choiceValues: { 1, 2 },
              label: "Radio Buttons",
              labelPosition: "ABOVE",
              value: local!field1,
              saveInto: {
                local!field1,
                if(
                  and(
                    local!field1 = 2,
                    a!isNotNullOrEmpty(local!field1)
                  ),
                  a!save(local!field2, null),
                  ""
                )
              },
              choiceLayout: "STACKED",
              validations: {}
            ),
            a!integerField(
              label: "Integer",
              labelPosition: "ABOVE",
              value: local!field2,
              saveInto: { local!field2 },
              refreshAfter: "UNFOCUS",
              validations: {},
              disabled:if(a!isNotNullOrEmpty(local!field1),
              local!field1=2,null)
            )
          },
          height: "AUTO",
          style: "TRANSPARENT",
          marginBelow: "STANDARD"
        )
      }
    )

    Write save on field 1 that makes field2 value null. Have a look into the sample code .

Reply
  • 0
    Certified Senior Developer

    a!localVariables(
      local!field1,
      local!field2,
      {
        a!cardLayout(
          contents: {
            a!radioButtonField(
              choiceLabels: { "Yes", "No" },
              choiceValues: { 1, 2 },
              label: "Radio Buttons",
              labelPosition: "ABOVE",
              value: local!field1,
              saveInto: {
                local!field1,
                if(
                  and(
                    local!field1 = 2,
                    a!isNotNullOrEmpty(local!field1)
                  ),
                  a!save(local!field2, null),
                  ""
                )
              },
              choiceLayout: "STACKED",
              validations: {}
            ),
            a!integerField(
              label: "Integer",
              labelPosition: "ABOVE",
              value: local!field2,
              saveInto: { local!field2 },
              refreshAfter: "UNFOCUS",
              validations: {},
              disabled:if(a!isNotNullOrEmpty(local!field1),
              local!field1=2,null)
            )
          },
          height: "AUTO",
          style: "TRANSPARENT",
          marginBelow: "STANDARD"
        )
      }
    )

    Write save on field 1 that makes field2 value null. Have a look into the sample code .

Children