diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/form/Form.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt | 8 |
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) } |