class Form<K : Any>
The form definition class. Can be used directly or indirectly inside a FormPanel.
Form(panel: FormPanel<K>? = null, serializer: KSerializer<K>)
Creates a form with a given modelFactory function |
val fields: MutableMap<String, FormControl> |
|
val modelFactory: (Map<String, Any?>) -> K |
fun <C : StringFormControl> add(key: KProperty1<K, String?>, control: C, required: Boolean = false, requiredMessage: String? = null, validatorMessage: ((C) -> String?)? = null, validator: ((C) -> Boolean?)? = null): Form<K>
Adds a string control to the form. fun <C : BoolFormControl> add(key: KProperty1<K, Boolean?>, control: C, required: Boolean = false, requiredMessage: String? = null, validatorMessage: ((C) -> String?)? = null, validator: ((C) -> Boolean?)? = null): Form<K>
Adds a boolean control to the form. fun <C : NumberFormControl> add(key: KProperty1<K, Number?>, control: C, required: Boolean = false, requiredMessage: String? = null, validatorMessage: ((C) -> String?)? = null, validator: ((C) -> Boolean?)? = null): Form<K>
Adds a number control to the form. fun <C : DateFormControl> add(key: KProperty1<K, Date?>, control: C, required: Boolean = false, requiredMessage: String? = null, validatorMessage: ((C) -> String?)? = null, validator: ((C) -> Boolean?)? = null): Form<K>
Adds a date control to the form. fun <C : KFilesFormControl> add(key: KProperty1<K, List<KFile>?>, control: C, required: Boolean = false, requiredMessage: String? = null, validatorMessage: ((C) -> String?)? = null, validator: ((C) -> Boolean?)? = null): Form<K>
Adds a files control to the form. |
|
fun clearData(): Unit
Sets the values of all controls to null. |
|
operator fun get(key: KProperty1<K, *>): Any?
Returns a value of the control of given key. |
|
fun getControl(key: KProperty1<K, *>): FormControl?
Returns a control of given key. |
|
fun getData(): K
Returns current data model. |
|
fun getDataJson(): Json
Returns current data model as JSON. |
|
fun remove(key: KProperty1<K, *>): Form<K>
Removes a control from the form. |
|
fun removeAll(): Form<K>
Removes all controls from the form. |
|
fun setData(model: K): Unit
Sets the values of all the controls from the model. |
|
fun validate(): Boolean
Invokes validator function and validates the form. |
fun <K : Any> create(panel: FormPanel<K>? = null, init: (Form<K>.() -> Unit)? = null): Form<K> |
fun <T> Any?.createInstance(vararg args: dynamic): T
Helper function for creating JavaScript objects from dynamic constructors. |
|
suspend fun <K : Any> Form<K>.getDataWithFileContent(): K
Returns current data model with file content read for all KFiles controls. |