FormControl
class FormControl[Owner, Input, Value, +Msg]The handle that renders one field's controls and error feedback.
Get one from field on a form value or a form signal, or from a FormBinding. A control from
a form value or a form signal uses the field's logical id and reports no blur feedback, so one
rendering helper serves live and static pages alike. A control from a binding scopes its ids to
the form instance, so several instances of one definition do not share DOM identities, and
reports blur under the binding's feedback policy.
view is a signal for rendering; read field data in handlers with fieldView on the form
value.
The control owns the id, name, value, type, checked, phx-change, and phx-blur
attributes of every control it renders, in any letter case. The control helpers throw
IllegalArgumentException when their mods set one, even one the control would not render. For
a custom control, use inputAttributes instead of a helper.
Parameters
viewThe field's current read-only data, for rendering. Its ids are not scoped to a form instance; render with this control's ids instead.
Defined by scalive.FormControl. View source (scalive/api/src/scalive/forms/FormBinding.scala:245-492)
Methods23
blurAttributes
def blurAttributes: Vector[Mod.Attr[Msg]]Interaction wiring only, for custom controls that own their id/name/value attributes. Composite widgets should send blurred when leaving their logical focus boundary instead.
Defined by scalive.FormControl.blurAttributes. View source (scalive/api/src/scalive/forms/FormBinding.scala:295-313)
checkbox
def checkbox[M >: Msg](checkedValue: String, mods: Mod.Input[M]*): HtmlElement[M]Renders a checkbox, checked when the retained raw values contain its checked value.
This form uses checkedValue, which must match the token the field's codec expects, as in
FieldInput.checkbox("yes") with control.checkbox("yes"). No hidden unchecked input is
rendered.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.checkbox. View source (scalive/api/src/scalive/forms/FormBinding.scala:413-422)
def checkbox[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a checkbox, checked when the retained raw values contain its checked value.
This form uses the checked value "true", matching FieldInput.checkbox(). No hidden
unchecked input is rendered.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.checkbox. View source (scalive/api/src/scalive/forms/FormBinding.scala:402-402)
date
def date[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a date input without parsing the retained raw scalar value. Native browser sanitization can make invalid raw dates appear empty.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.date. View source (scalive/api/src/scalive/forms/FormBinding.scala:359-360)
def email[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders an email input from the retained raw scalar value.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.email. View source (scalive/api/src/scalive/forms/FormBinding.scala:342-343)
errorFeedback
def errorFeedback(render: Signal[FormError[Owner]] => Mod[Nothing], mods: Mod.Input[Nothing]*): HtmlElement[Nothing]Renders the visible errors in an ARIA live feedback container whose id is errorId.
render draws one error; the container and its form-errors and form-error wrappers are
supplied. Overriding id, phx-feedback-for, or aria-live through mods is rejected.
Defined by scalive.FormControl.errorFeedback. View source (scalive/api/src/scalive/forms/FormBinding.scala:475-490)
errorId
def errorId: Signal[String]The DOM id of this control's error feedback container.
Defined by scalive.FormControl.errorId. View source (scalive/api/src/scalive/forms/FormBinding.scala:258-258)
fieldValue
def fieldValue: Signal[String]The value a scalar control renders: the last retained raw value, or empty when absent.
Defined by scalive.FormControl.fieldValue. View source (scalive/api/src/scalive/forms/FormBinding.scala:261-261)
hasVisibleErrors
def hasVisibleErrors: Signal[Boolean]Whether at least one field error is currently visible.
Defined by scalive.FormControl.hasVisibleErrors. View source (scalive/api/src/scalive/forms/FormBinding.scala:270-270)
id
def id: Signal[String]The control's DOM id, scoped to the form instance when bound. Use it for a label's forId.
Defined by scalive.FormControl.id. View source (scalive/api/src/scalive/forms/FormBinding.scala:252-252)
inputAttributes
def inputAttributes: Vector[Mod.Attr[Msg]]Scalar input identity, retained value, and blur wiring. Does not include type or ARIA.
Defined by scalive.FormControl.inputAttributes. View source (scalive/api/src/scalive/forms/FormBinding.scala:316-317)
item
def item(key: String): FormControlItem[Msg]Binds one checkbox choice with its own field-scoped identity.
The stable key is separate from the submitted value and must be unique among items rendered
for this control. Keys are encoded losslessly, including empty strings; null is rejected. Use
the returned id for labels, and this control's validation attributes and error feedback for
the shared field. Configure onBlur before creating items. Under AfterBlur, leaving any
checkbox blurs the field, even when focus moves to another item.
Defined by scalive.FormControl.item. View source (scalive/api/src/scalive/forms/FormBinding.scala:432-436)
name
def name: Signal[String]The browser field name, such as profile[name].
Defined by scalive.FormControl.name. View source (scalive/api/src/scalive/forms/FormBinding.scala:255-255)
onBlur
def onBlur[M >: Msg](f: String => M): FormControl[Owner, Input, Value, M]Returns a copy of this control that also sends an application message when the field blurs.
This form passes the browser value to f, as with on.blur.withValue. In a bound form, the
message follows feedback dispatch. Commands are ordered but do not wait for server
acknowledgements; this does not guarantee race-free normalization against later full-form
snapshots. Missing values (including unchecked checkboxes) become an empty string. A
multi-select supplies only its native scalar value here; use the form's change event for its
complete value vector.
Defined by scalive.FormControl.onBlur. View source (scalive/api/src/scalive/forms/FormBinding.scala:281-282)
def onBlur[M >: Msg](message: M): FormControl[Owner, Input, Value, M]Returns a copy of this control that also sends an application message when the field blurs.
This form sends message and ignores the browser value.
Defined by scalive.FormControl.onBlur. View source (scalive/api/src/scalive/forms/FormBinding.scala:288-289)
password
def password[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a password input from the retained raw scalar value.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.password. View source (scalive/api/src/scalive/forms/FormBinding.scala:375-376)
rawValues
def rawValues: Signal[Vector[String]]Every raw value retained for this field, before decoding.
Defined by scalive.FormControl.rawValues. View source (scalive/api/src/scalive/forms/FormBinding.scala:264-264)
search
def search[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a search input from the retained raw scalar value.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.search. View source (scalive/api/src/scalive/forms/FormBinding.scala:367-368)
select
def select[M >: Msg](options: Iterable[(String, String)], mods: Mod.Input[M]*): HtmlElement[M]Renders a select from (value, label) options, selecting each one in the retained raw values.
For a multiple select, use a repeated-value field such as Root.texts.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.select. View source (scalive/api/src/scalive/forms/FormBinding.scala:459-468)
tel
def tel[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a telephone input from the retained raw scalar value.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.tel. View source (scalive/api/src/scalive/forms/FormBinding.scala:350-351)
text
def text[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a text input from the retained raw scalar value.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.text. View source (scalive/api/src/scalive/forms/FormBinding.scala:334-335)
textarea
def textarea[M >: Msg](mods: Mod.Input[M]*): HtmlElement[M]Renders a textarea from the retained raw scalar value.
Throws IllegalArgumentException when mods sets an attribute this control owns; see
FormControl.
Defined by scalive.FormControl.textarea. View source (scalive/api/src/scalive/forms/FormBinding.scala:443-450)
validationAttributes
def validationAttributes: Vector[Mod.Attr[Nothing]]ARIA attributes linking the control to its error feedback and exposing visible invalidity.
The control helpers do not add them; pass them explicitly, as in
control.text(control.validationAttributes).
Defined by scalive.FormControl.validationAttributes. View source (scalive/api/src/scalive/forms/FormBinding.scala:324-327)
visibleErrors
def visibleErrors: Signal[Vector[FormError[Owner]]]The field's errors that the feedback policy currently makes visible.
Defined by scalive.FormControl.visibleErrors. View source (scalive/api/src/scalive/forms/FormBinding.scala:267-267)
Values1
view
val view: Signal[FormFieldView[Owner, Input, Value]]The field's current read-only data, for rendering. Its ids are not scoped to a form instance; render with this control's ids instead.
Defined by scalive.FormControl.view. View source (scalive/api/src/scalive/forms/FormBinding.scala:246-246)