RootedFormField
class RootedFormField[Owner, A]A form field carrying the phantom type of the FormRoot that owns it.
Its path is already rooted. The owner type restricts codec composition, initial values, and field access to values created by the same stable root.
Type parameters
Ownerthe singleton type of the owning root
Athe decoded field type
Defined by scalive.RootedFormField. View source (scalive/api/src/scalive/forms/FormDefinition.scala:315-390)
Methods11
codec
def codec: RootedFormCodec[Owner, A]Returns this field's decoder with the same root owner.
Defined by scalive.RootedFormField.codec. View source (scalive/api/src/scalive/forms/FormDefinition.scala:328-328)
id
def id: StringThe default DOM ID derived from path.
Defined by scalive.RootedFormField.id. View source (scalive/api/src/scalive/forms/FormDefinition.scala:325-325)
initial
def initial(values: String*): FormInitialValue[Owner]Creates an owner-checked raw initial value for this field.
Values are retained in argument order, including duplicates. They are decoded when passed to initial.
Defined by scalive.RootedFormField.initial. View source (scalive/api/src/scalive/forms/FormDefinition.scala:388-389)
map
def map[B](f: A => B): RootedFormField[Owner, B]Maps successful decoded values while preserving this field's path and owner.
Defined by scalive.RootedFormField.map. View source (scalive/api/src/scalive/forms/FormDefinition.scala:355-356)
name
def name: StringThe browser field name derived from path.
Defined by scalive.RootedFormField.name. View source (scalive/api/src/scalive/forms/FormDefinition.scala:322-322)
onChange
def onChange[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Binds a LiveView phx-change event decoded with this field's codec.
The callback receives a FormEvent for every change event; decoding failures remain in
event.value. The binding does not mutate any existing form state.
Defined by scalive.RootedFormField.onChange. View source (scalive/api/src/scalive/forms/FormDefinition.scala:335-336)
onRecover
def onRecover[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Binds a LiveView phx-auto-recover event decoded with this field's codec.
Recovery metadata is exposed through recovery. Decoding failures remain in
event.value and still invoke the callback.
Defined by scalive.RootedFormField.onRecover. View source (scalive/api/src/scalive/forms/FormDefinition.scala:351-352)
onSubmit
def onSubmit[Msg](f: FormEvent[A] => Msg): Mod.Attr[Msg]Binds a LiveView phx-submit event decoded with this field's codec.
The resulting event is marked submitted, so a form rebuilt from it treats all fields as used.
Decoding failures remain in event.value and still invoke the callback.
Defined by scalive.RootedFormField.onSubmit. View source (scalive/api/src/scalive/forms/FormDefinition.scala:343-344)
path
def path: FormPathThe complete field path, including its root.
Defined by scalive.RootedFormField.path. View source (scalive/api/src/scalive/forms/FormDefinition.scala:319-319)
required
def required(message: String = ..., code: Option[String] = ...)(using x$3: =:=[A, String]): RootedFormField[Owner, String]Requires the successfully decoded string to be non-empty.
This can follow map, allowing normalization such as trimming to happen before the required check. After preceding decoding and mapping succeed, an empty decoded string produces one error at path. Missing-field behavior is determined by the preceding decoder.
Defined by scalive.RootedFormField.required. View source (scalive/api/src/scalive/forms/FormDefinition.scala:376-381)
validate
def validate(message: String, code: Option[String] = ...)(predicate: A => Boolean): RootedFormField[Owner, A]Adds a validation that runs after this field has decoded successfully.
A false predicate produces one FormError at path, with message and optional code.
Defined by scalive.RootedFormField.validate. View source (scalive/api/src/scalive/forms/FormDefinition.scala:362-368)