In [6]:
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
In [5]:
// You can access the values from the form by treating it as an array indexed on the field names:
f['last'].reverse() + '...' + f['first']
Out[5]:
suilezreB...Beaker
In [4]:
// The array works both ways, so you set default values on the fields by writing the array:
f['first'] = 'Beaker'
f['last'] = 'Berzelius'
Out[4]:
Berzelius
In [7]:
h = new EasyForm("Form and Run")
h.addTextField("first", 380)
h.addTextArea("Text Area",500,200)
h
In [8]:
g2 = new EasyForm("Field Types")
options = ["a", "b", "c", "d"]
g2.addList("List Single", options, false)
g2.addList("List Two Row", options, 2)
g2
In [9]:
//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
In [7]:
f1['last']+ ", "+f1['first']
Out[7]:
setinit1, setinit1
In [8]:
f1['last'] = "new Value"
Out[8]:
new Value
In [9]:
f1['first'] = "new Value2"
Out[9]:
new Value2
In [10]:
//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
In [12]:
result = [:]
g.keySet().each {
  result[it] = g[it]
}
result
Out[12]:
{"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"}
In [13]:
gdp = new EasyForm("Field Types")
gdp.addDatePicker("Date")
gdp
In [14]:
gdp['Date']
Out[14]:
20170418
In [ ]: