aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-11-26 23:14:22 +0100
committerRobert Jaros <rjaros@finn.pl>2017-11-26 23:14:22 +0100
commit4261d6d2c73ac7786f0b107141d42a32ec9a1bf6 (patch)
tree212f93e67d131e8b5504789d6c0e389d4faed1d6
parent343390df5a0e01f45539939291c35d535a1b8af6 (diff)
downloadkvision-4261d6d2c73ac7786f0b107141d42a32ec9a1bf6.tar.gz
kvision-4261d6d2c73ac7786f0b107141d42a32ec9a1bf6.tar.bz2
kvision-4261d6d2c73ac7786f0b107141d42a32ec9a1bf6.zip
Form validation
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Form.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
index 66f6f450..337152e3 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
@@ -56,7 +56,7 @@ open class Form<K>(private val panel: FormPanel<K>? = null, private val modelFac
open fun getData(): K {
val map = fields.entries.associateBy({ it.key }, { it.value.getValue() })
- return modelFactory(map)
+ return modelFactory(map.withDefault { null })
}
open fun validate(): Boolean {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
index e996cfae..65015f3f 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
@@ -92,6 +92,14 @@ open class FormPanel<K>(private val type: FORMTYPE? = null, classes: Set<String>
return this
}
+ open fun getControl(key: String): FormControl? {
+ return form.getControl(key)
+ }
+
+ operator fun get(key: String): Any? {
+ return getControl(key)?.getValue()
+ }
+
open fun setData(data: K) {
form.setData(data)
}