f = new EasyForm("Form and Run")
f.addTextField("first", 250)
f['first'] = "First"
f.addTextField("last", 250)
f['last'] = "Last"
f.addButton("Go!", "run")
f
// You can access the values from the form by treating it as an array indexed on the field names:
f['last'].reverse() + '...' + f['first']
suilezreB...Beaker
// The array works both ways, so you set default values on the fields by writing the array:
f['first'] = 'Beaker'
f['last'] = 'Berzelius'
Berzelius
h = new EasyForm("Form and Run")
h.addTextField("first", 380)
h.addTextArea("Text Area",500,200)
h
g2 = new EasyForm("Field Types")
options = ["a", "b", "c", "d"]
g2.addList("List Single", options, false)
g2.addList("List Two Row", options, 2)
g2
//You can use onInit and onChange to handle component events. For button events use actionPerfromed or addAction.
f1 = new EasyForm("Form and Run")
f1.addTextField("first", 15)
f1.addTextField("last", 15).onInit({f1['last'] = "setinit1"}).onChange({text -> f1['first'] = text})
button = f1.addButton("action button")
button.actionPerformed = {f1['last'] = 'action done'}
f1
f1['last']+ ", "+f1['first']
setinit1, setinit1
f1['last'] = "new Value"
new Value
f1['first'] = "new Value2"
new Value2
//All Kinds of Fields
g = new EasyForm("Field Types")
g.addTextField("Short Text Field", 10)
g.addTextField("Text Field")
g.addTextArea("Text Area")
g.addCheckBox("Check Box")
options = ["a", "b", "c", "d"]
g.addComboBox("Combo Box", options)
g.addComboBox("Editable Combo", options, true)
g.addList("List", options)
g.addList("List Single", options, false)
g.addList("List Two Row", options, 2)
g.addCheckBoxes("Check Boxes", options)
g.addCheckBoxes("Check Boxes H", options, EasyForm.HORIZONTAL)
g.addRadioButtons("Radio Buttons", options)
g.addRadioButtons("Radio Buttons H", options, EasyForm.HORIZONTAL)
g.addDatePicker("Date")
g.addButton("Go!", "run2")
g
result = [:]
g.keySet().each {
result[it] = g[it]
}
result
{"Short Text Field":null,"Text Field":null,"Text Area":"","Check Box":"false","Combo Box":"a","Editable Combo":"a","List":null,"List Single":null,"List Two Row":null,"Check Boxes":"","Check Boxes H":"","Radio Buttons":null,"Radio Buttons H":"d","Date":"20170412"}
gdp = new EasyForm("Field Types")
gdp.addDatePicker("Date")
gdp
gdp['Date']
20170418