FormDefinition
class FormDefinition[Owner, A]A reusable, owner-checked definition of a rooted form.
A definition combines a root and whole-form codec. Its Owner parameter prevents forms, fields,
and initial values from different stable FormRoot values from being mixed.
Parameters
rootthe path prepended to fields in this definition
codecthe decoder used for initial values and LiveView form events
Type parameters
Ownerthe singleton type of the owning root
Athe decoded form value type
Defined by scalive.FormDefinition. View source (scalive/api/src/scalive/forms/FormDefinition.scala:419-478)
Types3
Field
type Field = ([B] =>> RootedFormField[Owner, B])A field type accepted by forms from this definition.
Defined by scalive.FormDefinition.Field. View source (scalive/api/src/scalive/forms/FormDefinition.scala:441-441)
Form
type Form = RootedForm[Owner, A]The rooted form type produced by this definition.
Defined by scalive.FormDefinition.Form. View source (scalive/api/src/scalive/forms/FormDefinition.scala:438-438)
InitialValue
type InitialValue = FormInitialValue[Owner]An initial-value type accepted by this definition.
Defined by scalive.FormDefinition.InitialValue. View source (scalive/api/src/scalive/forms/FormDefinition.scala:444-444)
Methods5
from
def from(event: FormEvent[A]): FormRebuilds this form from a typed event without running codec again.
Raw data, the already decoded value, and submission state are retained. Used-field state is derived from the event payload according to state.
Defined by scalive.FormDefinition.from. View source (scalive/api/src/scalive/forms/FormDefinition.scala:476-477)
def from(state: FormState[A]): FormWraps an existing decoded state without running codec again.
The caller is responsible for ensuring the state's raw data and decoded value belong to this definition.
Defined by scalive.FormDefinition.from. View source (scalive/api/src/scalive/forms/FormDefinition.scala:468-469)
initial
def initial(values: InitialValue*): FormCreates an unsubmitted form from owner-checked raw initial values.
Values and duplicates retain call order, and codec runs immediately. Decode errors are therefore present in state and errors from the first render. The new state is not submitted and has no used fields, so visibleErrors stays empty until the corresponding field is used or the form is submitted.
Defined by scalive.FormDefinition.initial. View source (scalive/api/src/scalive/forms/FormDefinition.scala:453-461)
onChange
def onChange[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Creates a typed change binding using this definition's stable codec.
Defined by scalive.FormDefinition.onChange. View source (scalive/api/src/scalive/forms/FormDefinition.scala:426-427)
onRecover
def onRecover[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Creates a typed recovery binding using this definition's stable codec.
Defined by scalive.FormDefinition.onRecover. View source (scalive/api/src/scalive/forms/FormDefinition.scala:434-435)
onSubmit
def onSubmit[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Creates a typed submit binding using this definition's stable codec.
Defined by scalive.FormDefinition.onSubmit. View source (scalive/api/src/scalive/forms/FormDefinition.scala:430-431)
Values2
codec
val codec: FormCodec[A]Defined by scalive.FormDefinition.codec. View source (scalive/api/src/scalive/forms/FormDefinition.scala:423-423)
root
val root: FormPathDefined by scalive.FormDefinition.root. View source (scalive/api/src/scalive/forms/FormDefinition.scala:421-421)