View Source PetalComponents.Field (petal_components v1.1.1)

Link to this section Summary

Functions

Renders an input with label and error messages. If you just want an input, check out input.ex

Generates a generic error message.

Renders a label.

Attributes

  • class (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • name (:string) Global attributes are accepted.

Slots

  • inner_block (required)

Link to this section Functions

Renders an input with label and error messages. If you just want an input, check out input.ex

A %Phoenix.HTML.FormField{} and type may be passed to the field to build input names and error messages, or all the attributes and errors may be passed explicitly.

examples

Examples

<.field field={@form[:email]} type="email" />
<.field label="Name" value="" name="name" errors={["oh no!"]} />

attributes

Attributes

  • id (:any) - the id of the input. If not passed, it will be generated automatically from the field. Defaults to nil.
  • name (:any) - the name of the input. If not passed, it will be generated automatically from the field.
  • label (:string) - the label for the input. If not passed, it will be generated automatically from the field.
  • value (:any) - the value of the input. If not passed, it will be generated automatically from the field.
  • type (:string) - the type of input. Defaults to "text".
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].
  • errors (:list) - a list of errors to display. If not passed, it will be generated automatically from the field. Format is a list of strings. Defaults to [].
  • checked (:any) - the checked flag for checkboxes and checkbox groups.
  • prompt (:string) - the prompt for select inputs. Defaults to nil.
  • options (:list) - the options to pass to Phoenix.HTML.Form.options_for_select/2.
  • multiple (:boolean) - the multiple flag for select inputs. Defaults to false.
  • group_layout (:atom) - the layout of the inputs in a group (checkbox_group or radio_group). Defaults to :row.
  • class (:string) - the class to add to the input. Defaults to nil.
  • wrapper_class (:string) - the wrapper div classes. Defaults to nil. Global attributes are accepted.

Generates a generic error message.

slots

Slots

  • inner_block (required)

Renders a label.

attributes

Attributes

  • for (:string) - Defaults to nil.
  • class (:string) - Defaults to nil. Global attributes are accepted.

slots

Slots

  • inner_block (required)

attributes

Attributes

  • class (:string) - Defaults to nil.
  • errors (:list) - Defaults to [].
  • name (:string) Global attributes are accepted.

slots

Slots

  • inner_block (required)