aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-01-16 15:53:33 +0100
committerRobert Jaros <rjaros@finn.pl>2018-01-16 15:53:33 +0100
commit0ecae6728903740c4407fd4bb9ebab806c631f2f (patch)
treecb819fab1a7d5046ec54801706c534e0179caad0 /src
parent2c4fe2ef6fd0a0bfa53f6496a1d4bede8fe9219d (diff)
downloadkvision-0ecae6728903740c4407fd4bb9ebab806c631f2f.tar.gz
kvision-0ecae6728903740c4407fd4bb9ebab806c631f2f.tar.bz2
kvision-0ecae6728903740c4407fd4bb9ebab806c631f2f.zip
Radio button group form control
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/Showcase.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt4
3 files changed, 10 insertions, 4 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt
index dfdc5b6b..d7b76862 100644
--- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt
@@ -462,7 +462,13 @@ class Showcase : ApplicationBase() {
}, required = true)
add("spinner", Spinner(label = "Spinner"), required = true)
add("radiogroup", RadioGroup(listOf("o1" to "Pierwsza opcja", "o2" to "Druga opcja"),
- inline = true, label = "Radio group"), required = true)
+ inline = true, label = "Radio group").apply {
+ setEventListener<RadioGroup> {
+ change = { e ->
+ println(self.value)
+ }
+ }
+ }, required = true)
validator = {
val result = it["text"] == it["textarea"]
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
index 1a28870a..696e2264 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
@@ -86,7 +86,7 @@ open class Radio(value: Boolean = false, extraValue: String? = null, label: Stri
init {
@Suppress("LeakingThis")
- input.eventTarget = this
+ input.eventTarget = this.eventTarget ?: this
this.addInternal(input)
this.addInternal(flabel)
this.addInternal(validationInfo)
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
index 43a0d4e4..50bd49fc 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
@@ -55,7 +55,6 @@ open class RadioGroup(options: List<StringPair>? = null, value: String? = null,
final override val validationInfo: HelpBlock = HelpBlock().apply { visible = false }
init {
- @Suppress("LeakingThis")
setChildrenFromOptions()
counter++
}
@@ -103,8 +102,9 @@ open class RadioGroup(options: List<StringPair>? = null, value: String? = null,
Radio(false, extraValue = it.first, label = it.second).apply {
inline = tinline
name = tidc
+ eventTarget = this@RadioGroup
setEventListener<Radio> {
- change = {
+ change = { e ->
this@RadioGroup.value = self.extraValue
}
}