Skip to main content
September 1, 2021
Solved

How to refresh textfield to be blank after click any button?

  • September 1, 2021
  • 12 replies
  • 0 views

As title

    Best answer by siddharthm0003

    Here is a simple code snippet that should help you achieve this functionality. As mentioned by other practitioners, you set the value of your text input to null in the button's saveInto

    a!localVariables(
      local!text,
      {
        a!textField(
          label: "Input",
          value: local!text,
          saveInto: local!text
        ),
        a!buttonArrayLayout(
          buttons: a!buttonWidget(
            label: "REFRESH INPUT FIELD",
            saveInto: { a!save(local!text, null()) }
          )
        )
      }
    )

    12 replies

    stefanhelzle0001
    Brainy
    September 1, 2021

    The value a field shows is stored in a local variable or rule input. To blank the field you need to modify the underlying value using a saveInto.

    September 1, 2021

    do you mean like saveInto:{ri!input,

    a!save(),a!save()

    }?

    harshas2775
    Brainy
    September 1, 2021

    If for example, you are saving value of the textfield in variable ri!inputText, then within the buttons' saveInto do a!save(ri!nputText,""). now whenever you click on any such button, ri!inputText will become blank.

    September 1, 2021

    but this way may cause ri!inputvalue becomes empty to the database right? I just want it to be saved rightly with value plus the textfield to be blank

    September 2, 2021

    Here is a simple code snippet that should help you achieve this functionality. As mentioned by other practitioners, you set the value of your text input to null in the button's saveInto

    a!localVariables(
      local!text,
      {
        a!textField(
          label: "Input",
          value: local!text,
          saveInto: local!text
        ),
        a!buttonArrayLayout(
          buttons: a!buttonWidget(
            label: "REFRESH INPUT FIELD",
            saveInto: { a!save(local!text, null()) }
          )
        )
      }
    )

    September 2, 2021

    You are right!