Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline
c

FormState

class FormState[+A](raw: FormData, value: Either[FormErrors, A], used: Set[FormPath], submitted: Boolean)

Decoded form data together with validation visibility state.

The four-argument case-class constructor is intentionally low-level: it does not verify that value was decoded from raw or that used agrees with the payload. The three-argument The three-argument apply derives used paths from LiveView's _unused_ markers and is the usual constructor for received form data.

Parameters

raw

the ordered form payload used for rendering raw field values

value

either ordered validation errors or the decoded value

used

exact paths marked used; inspect through isUsed when rendering validation feedback

submitted

whether the state came from a typed phx-submit binding; when true, isUsed returns true for every path, including paths absent from used

Type parameters

A

the successfully decoded form value

Defined by scalive.FormState. View source (scalive/api/src/scalive/forms/FormState.scala:31-63)

Methods5

errors

def errors: FormErrors

The decoding errors, or empty when valid.

Defined by scalive.FormState.errors. View source (scalive/api/src/scalive/forms/FormState.scala:40-40)

errorsFor

def errorsFor(name: String): Vector[FormError]

Permissively parses name, then returns matching validation errors in order.

Defined by scalive.FormState.errorsFor. View source (scalive/api/src/scalive/forms/FormState.scala:61-62)

def errorsFor(path: FormPath): Vector[FormError]

Returns validation errors at exactly path, preserving order.

Defined by scalive.FormState.errorsFor. View source (scalive/api/src/scalive/forms/FormState.scala:57-58)

isUsed

def isUsed(name: String): Boolean

Permissively parses name, then checks whether that path is used.

Defined by scalive.FormState.isUsed. View source (scalive/api/src/scalive/forms/FormState.scala:53-54)

def isUsed(path: FormPath): Boolean

Whether validation feedback for path should be visible.

Every path is considered used after submission; otherwise membership in used is exact.

Defined by scalive.FormState.isUsed. View source (scalive/api/src/scalive/forms/FormState.scala:49-50)

isValid

def isValid: Boolean

Whether decoding and validation succeeded.

Defined by scalive.FormState.isValid. View source (scalive/api/src/scalive/forms/FormState.scala:37-37)

valueOption

def valueOption: Option[A]

The decoded value when valid.

Defined by scalive.FormState.valueOption. View source (scalive/api/src/scalive/forms/FormState.scala:43-43)

Values4

raw

val raw: FormData

Defined by scalive.FormState.raw. View source (scalive/api/src/scalive/forms/FormState.scala:32-32)

submitted

val submitted: Boolean

Defined by scalive.FormState.submitted. View source (scalive/api/src/scalive/forms/FormState.scala:35-35)

used

val used: Set[FormPath]

Defined by scalive.FormState.used. View source (scalive/api/src/scalive/forms/FormState.scala:34-34)

value

val value: util.Either[FormErrors, A]

Defined by scalive.FormState.value. View source (scalive/api/src/scalive/forms/FormState.scala:33-33)