Skip to main content
New Participant
Jun 6, 2022 10:13 AM UTC
Question

clear form data

Hello, I have a problem when trying to clean the data of a form by means of a button.
The case is that I have an array of objects, and a button that when I press it saves an object in the array with the form data and creates another object. The problem is that when I press the button I also want to clean the form, because now I save the object in the array but the values remain in the form.
Thank you!

Translated with www.DeepL.com/Translator (free version)

2 replies

stefanhelzle0001
Brainy
Jun 6, 2022 12:22 PM UTC

You need to clean the data used as the value for your input fields. Add one or more a!save() to the saveInto parameter of your button.

arulk0002
Inspiring
Jun 9, 2022 2:13 AM UTC

I used to save the data in the local variable. when the button clicked, the data will be saved into the target file and simultaneously the value(localvariable) will be null. Hope this code will help you..

a!localVariables(
local!name,
a!formLayout(
label: "Form",
contents: {
a!textField(
label: "Text",
labelPosition: "ABOVE",
value: local!name,
saveInto: {
local!name
},
refreshAfter: "UNFOCUS",
validations: {}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
submit: true,
saveInto: {
a!save(
ri!name, local!name
),
a!save(
local!name, ""
)
},
style: "PRIMARY",
loadingIndicator: true
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: true,
saveInto: {},
submit: true,
style: "NORMAL",
validate: false
)
}
)
)
)