View Source ZoonkWeb.Components.Input (Zoonk v0.3.0-alpha)

Input components.

Link to this section Summary

Functions

Generates a generic error message.

Renders a helper text.

Renders an input with label and error messages.

Renders a label.

Translates an error message using gettext.

Link to this section Functions

Generates a generic error message.

slots

Slots

  • inner_block (required)

Renders a helper text.

slots

Slots

  • inner_block (required)

Renders an input with label and error messages.

A %Form{} and field name may be passed to the input to build input names and error messages, or all the attributes and errors may be passed explicitly.

examples

Examples

<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />

attributes

Attributes

  • id (:any) - the id of the input. Defaults to nil.
  • name (:any) - the name of the input.
  • label (:string) - the label of the input. Defaults to nil.
  • value (:any) - the value of the input.
  • helper (:string) - a helper text to be displayed with the input. Defaults to nil.
  • type (:string) - Defaults to "text".
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].
  • errors (:list) - the errors to display for the input. Defaults to [].
  • checked (:boolean) - the checked flag for checkbox inputs.
  • prompt (:string) - the prompt for select inputs. Defaults to nil.
  • options (:list) - the options to pass to Form.options_for_select/2.
  • multiple (:boolean) - the multiple flag for select inputs. Defaults to false.
  • Global attributes are accepted.

slots

Slots

  • inner_block - the inner block of the input.

Renders a label.

attributes

Attributes

  • for (:string) - Defaults to nil.

slots

Slots

  • inner_block (required)

Translates an error message using gettext.