kvision / pl.treksoft.kvision.form / FormPanel

FormPanel

open class FormPanel<K> : SimplePanel

Bootstrap form component.

Constructors

<init>

FormPanel(type: FORMTYPE? = null, classes: Set<String> = setOf(), modelFactory: (Map<String, Any?>) -> K)

Properties

validator

var validator: (Form<K>) -> Boolean?

Validation function.

validatorMessage

var validatorMessage: (Form<K>) -> String?

Function returning validation message.

Functions

add

open fun <C : FormControl> add(key: String, control: C, required: Boolean = false, validatorMessage: (C) -> String? = null, validator: (C) -> Boolean? = null): FormPanel<K>

Adds a control to the form panel.

clearData

open fun clearData(): Unit

Sets the values of all controls to null.

get

operator fun get(key: String): Any?

Returns a value of the control of given key.

getControl

open fun getControl(key: String): FormControl?

Returns a control of given key.

getData

open fun getData(): K

Returns current data model.

getDataJson

open fun getDataJson(): Json

Returns current data model as JSON.

getSnClass

open fun getSnClass(): List<StringBoolPair>

Returns list of CSS class names for current widget in the form of a List.

remove

open fun remove(key: String): FormPanel<K>

Removes a control from the form panel.

removeAll

open fun removeAll(): FormPanel<K>

Removes all children from the current container.

render

open fun render(): VNode

Renders current component as a Snabbdom vnode.

setData

open fun setData(model: K): Unit

Sets the values of all the controls from the model.

validate

open fun validate(): Boolean

Invokes validator function and validates the form.

Inherited Functions

add

open fun add(child: Component): SimplePanel

Adds given component to the current container.

addAll

open fun addAll(children: List<Component>): SimplePanel

Adds a list of components to the current container.

addInternal

fun addInternal(child: Component): SimplePanel

Protected and final method to add given component to the current container.

childrenVNodes

open fun childrenVNodes(): Array<VNode>

Returns the array of the children Snabbdom vnodes.

getChildren

open fun getChildren(): List<Component>

Returns a list of children of the current container.

remove

open fun remove(child: Component): SimplePanel

Removes given component from the current container.