Skip to content
scalive
Menu
ConnectingLiveReconnectingOffline
c

Form

class Form[A](root: FormPath, state: FormState[A], codec: FormCodec[A])

Lower-level form model with a runtime root, current state, and event codec.

Prefer FormRoot and FormDefinition for new forms: their RootedForm facade enforces field ownership at compile time. This unowned API accepts relative paths and supports states containing either rooted browser names or legacy relative names. Path-based value and raw-value lookup tries the rooted path first, then the relative path; error lookup combines both, and used state accepts either. A typed FormField is expected to contain its complete path and is checked against root at runtime, unless the root is empty.

Parameters

root

the path prepended to relative field paths; an empty path makes the form unrooted

state

the current raw, decoded, used-field, and submission state

codec

the codec used by typed LiveView event bindings

Type parameters

A

the decoded whole-form value type

Defined by scalive.Form. View source (scalive/api/src/scalive/forms/Form.scala:23-266)

Methods20

checkbox

def checkbox[Msg](path: String, checkedValue: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a checkbox with checkedValue as its submitted value.

Defined by scalive.Form.checkbox. View source (scalive/api/src/scalive/forms/Form.scala:171-172)

def checkbox[Msg](path: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a checkbox whose submitted value is "true".

Defined by scalive.Form.checkbox. View source (scalive/api/src/scalive/forms/Form.scala:167-168)

def checkbox[Msg](path: FormPath, checkedValue: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a checkbox with checkedValue as its submitted value.

Defined by scalive.Form.checkbox. View source (scalive/api/src/scalive/forms/Form.scala:179-180)

def checkbox[Msg](path: FormPath, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a checkbox whose submitted value is "true".

Defined by scalive.Form.checkbox. View source (scalive/api/src/scalive/forms/Form.scala:175-176)

disableRecovery

def disableRecovery: Mod.Attr[Nothing]

Disables Phoenix's automatic form recovery by rendering phx-auto-recover="ignore".

Defined by scalive.Form.disableRecovery. View source (scalive/api/src/scalive/forms/Form.scala:56-57)

email

def email[Msg](path: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders an email input for a relative field path.

Defined by scalive.Form.email. View source (scalive/api/src/scalive/forms/Form.scala:143-144)

def email[Msg](path: FormPath, mods: Mod[Msg]*): HtmlElement[Msg]

Renders an email input for a relative field path.

Defined by scalive.Form.email. View source (scalive/api/src/scalive/forms/Form.scala:147-148)

errors

def errors(path: String): HtmlElement[Nothing]

Renders the distinct current errors for a relative field path.

This helper does not apply used-field visibility rules. Prefer errorFeedback when errors should appear only after interaction and be paired with control accessibility attributes.

Defined by scalive.Form.errors. View source (scalive/api/src/scalive/forms/Form.scala:212-213)

def errors(path: FormPath): HtmlElement[Nothing]

Renders the distinct current errors for a relative field path.

Errors stored under the exact relative and rooted paths are combined and deduplicated. The wrapper has class form-errors; each message is a span.form-error.

Defined by scalive.Form.errors. View source (scalive/api/src/scalive/forms/Form.scala:220-224)

errorsFor

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

Returns the distinct current errors for a relative field path, regardless of visibility.

Defined by scalive.Form.errorsFor. View source (scalive/api/src/scalive/forms/Form.scala:238-239)

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

Returns the distinct current errors for a relative field path, regardless of visibility.

Errors stored under the exact relative and rooted paths are combined and deduplicated while preserving their first occurrence.

Defined by scalive.Form.errorsFor. View source (scalive/api/src/scalive/forms/Form.scala:246-249)

feedback

def feedback(path: String, mods: Mod[Nothing]*): HtmlElement[Nothing]

Renders a Phoenix feedback container for a relative field path.

Defined by scalive.Form.feedback. View source (scalive/api/src/scalive/forms/Form.scala:227-228)

def feedback(path: FormPath, mods: Mod[Nothing]*): HtmlElement[Nothing]

Renders a div with phx-feedback-for set to the rooted field name.

Caller modifiers, including content, are appended to the container.

Defined by scalive.Form.feedback. View source (scalive/api/src/scalive/forms/Form.scala:234-235)

field

def field(path: String): FormFieldView[Vector[String]]

Returns an untyped view of a relative field path.

The view reads values from the rooted path first and falls back to the exact relative path.

Defined by scalive.Form.field. View source (scalive/api/src/scalive/forms/Form.scala:71-72)

def field(path: FormPath): FormFieldView[Vector[String]]

Returns an untyped view of a relative field path.

Raw display values use the rooted path first and fall back to the exact relative path. The view's decoded value is always decoded from the rooted field path.

Defined by scalive.Form.field. View source (scalive/api/src/scalive/forms/Form.scala:79-80)

def field[B](definition: FormField[B]): FormFieldView[B]

Returns the current view of a typed, fully rooted field definition.

Unlike the path overloads, this performs no relative fallback.

Throws

IllegalArgumentException

if this form has a non-empty root and the field path is outside it

Defined by scalive.Form.field. View source (scalive/api/src/scalive/forms/Form.scala:89-94)

hidden

def hidden[Msg](path: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a hidden input for a relative field path.

Defined by scalive.Form.hidden. View source (scalive/api/src/scalive/forms/Form.scala:159-160)

def hidden[Msg](path: FormPath, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a hidden input for a relative field path.

Defined by scalive.Form.hidden. View source (scalive/api/src/scalive/forms/Form.scala:163-164)

id

def id(path: String): String

Returns the default DOM ID for a relative field path.

Defined by scalive.Form.id. View source (scalive/api/src/scalive/forms/Form.scala:105-106)

def id(path: FormPath): String

Returns the default DOM ID for a relative field path.

Defined by scalive.Form.id. View source (scalive/api/src/scalive/forms/Form.scala:109-110)

isUsed

def isUsed(path: String): Boolean

Tests whether a relative field is eligible to show errors.

Defined by scalive.Form.isUsed. View source (scalive/api/src/scalive/forms/Form.scala:252-253)

def isUsed(path: FormPath): Boolean

Tests whether a relative field is eligible to show errors.

Either the exact relative or rooted path may mark it used; a submitted form treats every path as used.

Defined by scalive.Form.isUsed. View source (scalive/api/src/scalive/forms/Form.scala:260-261)

name

def name(path: String): String

Returns the rooted browser name for a relative field path.

Defined by scalive.Form.name. View source (scalive/api/src/scalive/forms/Form.scala:97-98)

def name(path: FormPath): String

Returns the rooted browser name for a relative field path.

Defined by scalive.Form.name. View source (scalive/api/src/scalive/forms/Form.scala:101-102)

onChange

def onChange[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]

Binds phx-change and decodes each event with codec.

The callback runs for successful and failed decodes. It receives a new FormEvent but this immutable form is not updated automatically.

Defined by scalive.Form.onChange. View source (scalive/api/src/scalive/forms/Form.scala:40-41)

onRecover

def onRecover[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]

Binds phx-auto-recover and decodes recovery events with codec.

Defined by scalive.Form.onRecover. View source (scalive/api/src/scalive/forms/Form.scala:52-53)

onSubmit

def onSubmit[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]

Binds phx-submit and decodes each event with codec.

The event is marked submitted, making every field used when converted to FormState. The callback also runs when decoding fails.

Defined by scalive.Form.onSubmit. View source (scalive/api/src/scalive/forms/Form.scala:48-49)

password

def password[Msg](path: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a password input for a relative field path.

Defined by scalive.Form.password. View source (scalive/api/src/scalive/forms/Form.scala:151-152)

def password[Msg](path: FormPath, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a password input for a relative field path.

Defined by scalive.Form.password. View source (scalive/api/src/scalive/forms/Form.scala:155-156)

select

def select[Msg](path: String, options: Iterable[(String, String)], mods: Mod[Msg]*): HtmlElement[Msg]

Renders a select whose options are (submittedValue, label) pairs.

Defined by scalive.Form.select. View source (scalive/api/src/scalive/forms/Form.scala:191-196)

def select[Msg](path: FormPath, options: Iterable[(String, String)], mods: Mod[Msg]*): HtmlElement[Msg]

Renders a select whose options are (submittedValue, label) pairs.

Defined by scalive.Form.select. View source (scalive/api/src/scalive/forms/Form.scala:199-204)

text

def text[Msg](path: String, explicitId: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a text input with an explicit DOM ID for a relative field path.

Defined by scalive.Form.text. View source (scalive/api/src/scalive/forms/Form.scala:135-136)

def text[Msg](path: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a text input for a relative field path.

Defined by scalive.Form.text. View source (scalive/api/src/scalive/forms/Form.scala:127-128)

def text[Msg](path: FormPath, explicitId: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a text input with an explicit DOM ID for a relative field path.

Defined by scalive.Form.text. View source (scalive/api/src/scalive/forms/Form.scala:139-140)

def text[Msg](path: FormPath, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a text input for a relative field path.

Defined by scalive.Form.text. View source (scalive/api/src/scalive/forms/Form.scala:131-132)

textarea

def textarea[Msg](path: String, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a textarea for a relative field path.

Defined by scalive.Form.textarea. View source (scalive/api/src/scalive/forms/Form.scala:183-184)

def textarea[Msg](path: FormPath, mods: Mod[Msg]*): HtmlElement[Msg]

Renders a textarea for a relative field path.

Defined by scalive.Form.textarea. View source (scalive/api/src/scalive/forms/Form.scala:187-188)

triggerHttpSubmitWhen

def triggerHttpSubmitWhen(condition: Boolean): Mod.Attr[Nothing]

Renders phx-trigger-action when condition is true.

On a form with an ordinary action and method, Phoenix uses this attribute to hand a Live submit back to the browser for normal HTTP submission.

Defined by scalive.Form.triggerHttpSubmitWhen. View source (scalive/api/src/scalive/forms/Form.scala:64-65)

value

def value(path: String): String

Returns the last raw value for a relative field path, or the empty string.

The rooted path is tried first, followed by the exact relative path.

Defined by scalive.Form.value. View source (scalive/api/src/scalive/forms/Form.scala:116-117)

def value(path: FormPath): String

Returns the last raw value for a relative field path, or the empty string.

The rooted path is tried first, followed by the exact relative path.

Defined by scalive.Form.value. View source (scalive/api/src/scalive/forms/Form.scala:123-124)

Values3

codec

val codec: FormCodec[A]

Defined by scalive.Form.codec. View source (scalive/api/src/scalive/forms/Form.scala:23-23)

root

val root: FormPath

Defined by scalive.Form.root. View source (scalive/api/src/scalive/forms/Form.scala:23-23)

state

val state: FormState[A]

Defined by scalive.Form.state. View source (scalive/api/src/scalive/forms/Form.scala:23-23)