PhiaUi.Components.PhiaInput (phia_ui v0.1.17)

Copy Markdown View Source

Form-aware standalone input component for Phoenix LiveView.

phia_input/1 renders a complete input field — label, optional description, <input> element, and inline validation errors — bound directly to a Phoenix.HTML.FormField. It is the all-in-one alternative to composing form_field/1 with a bare <input>.

Usage

<.phia_input field={@form[:email]} type="email" label="Email address" />

<.phia_input
  field={@form[:username]}
  label="Username"
  description="3–20 characters, letters and numbers only"
  phx-debounce="300"
/>

<.phia_input field={@form[:password]} type="password" label="Password" />

Error display

Errors are sourced from field.errors and translated via the built-in placeholder interpolator, or the configured {Module, :function} set in:

config :phia_ui, :error_translator_function, {MyApp.CoreComponents, :translate_error}

Global attributes

The following HTML attributes are forwarded to the <input> element via the :global attribute: autocomplete, readonly, disabled, step, max, min, placeholder, phx-debounce.

Summary

Functions

phia_input(assigns)

Attributes

  • field (Phoenix.HTML.FormField) (required)
  • type (:string) - Defaults to "text".
  • label (:string) - Defaults to nil.
  • description (:string) - Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["autocomplete", "readonly", "disabled", "step", "max", "min", "placeholder", "phx-debounce"].