aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/Text.kt
blob: 0980099f17da9cb2353cef8a20822af3b628543d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package pl.treksoft.kvision.form

import pl.treksoft.kvision.core.Container


open class Text(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, placeholder: String? = null, value: String? = null,
                name: String? = null, maxlength: Int? = null, label: String? = null, rich: Boolean = false,
                disabled: Boolean = false) : Container(setOf("form-group")), StringFormField {

    override var value
        get() = input.value
        set(value) {
            input.value = value
        }
    var startValue
        get() = input.startValue
        set(value) {
            input.startValue = value
        }
    var type
        get() = input.type
        set(value) {
            input.type = value
        }
    var placeholder
        get() = input.placeholder
        set(value) {
            input.placeholder = value
        }
    var name
        get() = input.name
        set(value) {
            input.name = value
        }
    var maxlength
        get() = input.maxlength
        set(value) {
            input.maxlength = value
        }
    override var disabled
        get() = input.disabled
        set(value) {
            input.disabled = value
        }
    var label
        get() = flabel.text
        set(value) {
            flabel.text = value
        }
    var rich
        get() = flabel.rich
        set(value) {
            flabel.rich = value
        }
    override var size
        get() = input.size
        set(value) {
            input.size = value
        }

    private val idc = "kv_form_text_" + counter
    internal val input: TextInput = TextInput(type, placeholder, value, name, maxlength, disabled, idc)
    internal val flabel: FieldLabel = FieldLabel(idc, label, rich)

    init {
        this.addInternal(flabel)
        this.addInternal(input)
        counter++
    }

    companion object {
        var counter = 0
    }

}