FormField
class FormField[A]A typed form field that owns its path and decoding rules.
Field transformations retain the path. A field's codec reads all raw values for the exact rendered name, allowing scalar constructors to reject duplicates rather than silently selecting one.
For example:
val Name = FormField
.string(FormPath("profile", "name"))
.map(_.trim)
.required("Name is required", Some("required"))Parameters
paththe exact field path used for names, ids, raw values, and validation added by field methods
codecthe codec used by bindings and validation
Type parameters
Athe successfully decoded field value
Defined by scalive.FormField. View source (scalive/api/src/scalive/forms/FormField.scala:24-82)
Methods8
id
def id: StringThe conventional, potentially non-unique DOM id rendered from path.
Defined by scalive.FormField.id. View source (scalive/api/src/scalive/forms/FormField.scala:32-32)
map
def map[B](f: A => B): FormField[B]Transforms a successfully decoded value while retaining this field's path.
If the current codec fails, f is not evaluated.
Defined by scalive.FormField.map. View source (scalive/api/src/scalive/forms/FormField.scala:50-51)
name
def name: StringThe browser field name rendered from path.
Defined by scalive.FormField.name. View source (scalive/api/src/scalive/forms/FormField.scala:29-29)
onChange
def onChange[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Creates a phx-change binding that decodes this field into a typed FormEvent.
Defined by scalive.FormField.onChange. View source (scalive/api/src/scalive/forms/FormField.scala:35-36)
onRecover
def onRecover[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Creates a LiveView auto-recovery binding that decodes this field into a FormEvent.
Defined by scalive.FormField.onRecover. View source (scalive/api/src/scalive/forms/FormField.scala:43-44)
onSubmit
def onSubmit[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Creates a phx-submit binding that decodes this field into a submitted FormEvent.
Defined by scalive.FormField.onSubmit. View source (scalive/api/src/scalive/forms/FormField.scala:39-40)
required
def required(message: String = ..., code: Option[String] = ...)(using ev: =:=[A, String]): FormField[String]Requires a decoded String to be non-empty.
This validation runs after prior mappings, so normalization such as map(_.trim) can define
blankness. Without such a mapping, whitespace-only strings are accepted. Earlier decoding
failures, including duplicate errors from string, short-circuit this validation.
Defined by scalive.FormField.required. View source (scalive/api/src/scalive/forms/FormField.scala:76-81)
validate
def validate(message: String, code: Option[String] = ...)(predicate: A => Boolean): FormField[A]Adds a predicate validation after all existing decoding and transformations.
A false predicate returns one error at this field's path. If an earlier stage fails, the predicate is not run and only the earlier errors are returned; chain separate fields with zip when independent errors should accumulate.
Defined by scalive.FormField.validate. View source (scalive/api/src/scalive/forms/FormField.scala:59-68)
Values2
codec
val codec: FormCodec[A]Defined by scalive.FormField.codec. View source (scalive/api/src/scalive/forms/FormField.scala:26-26)
path
val path: FormPathDefined by scalive.FormField.path. View source (scalive/api/src/scalive/forms/FormField.scala:25-25)