Form input components: text input, select, and checkbox.
All components integrate with Phoenix.HTML.Form and changeset errors.
Summary
Functions
Renders a checkbox with label and error support for use inside forms.
Renders a labelled text input.
Renders a labelled select dropdown.
Functions
Renders a checkbox with label and error support for use inside forms.
Examples
<.checkbox_field field={@form[:agree]} label="Concordo com os termos" />
<.checkbox_field name="newsletter" checked={@subscribed} label="Receber newsletter" />Attributes
id(:any) - Defaults tonil.name(:any) - Defaults tonil.label(:string) (required)checked(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.errors(:list) - Defaults to[].field(Phoenix.HTML.FormField) - a form field struct.- Global attributes are accepted.
Renders a labelled text input.
Examples
<.input field={@form[:email]} label="Email" type="email" required />
<.input name="search" value={@query} placeholder="Pesquisar..." />Attributes
id(:any) - Defaults tonil.name(:any) - Defaults tonil.label(:string) - Defaults tonil.value(:any) - Defaults tonil.type(:string) - Defaults to"text".placeholder(:string) - Defaults tonil.required(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.hint(:string) - Defaults tonil.errors(:list) - Defaults to[].field(Phoenix.HTML.FormField) - a form field struct, e.g. @form[:email].class(:string) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["autocomplete", "maxlength", "minlength", "pattern", "readonly", "phx-debounce"].
Renders a labelled select dropdown.
Examples
<.select field={@form[:role]} label="Função" options={[{"Admin", "admin"}, {"User", "user"}]} />
<.select name="country" label="País" options={@countries} prompt="Selecionar..." />Attributes
id(:any) - Defaults tonil.name(:any) - Defaults tonil.label(:string) - Defaults tonil.value(:any) - Defaults tonil.options(:list) (required)prompt(:string) - Defaults tonil.required(:boolean) - Defaults tofalse.disabled(:boolean) - Defaults tofalse.errors(:list) - Defaults to[].field(Phoenix.HTML.FormField) - a form field struct.class(:string) - Defaults tonil.- Global attributes are accepted.