View Source Torch.Component (Torch v5.0.0-rc.4)

Provides Phoenix.Components for use in Torch views and layouts

Link to this section Summary

Functions

Returns a formatted group of all flash messages available.

Renders generic error message

Renders a simple flash message tag

Renders a Torch form input with label and error messages.

Renders a label

Translates an error message using gettext.

Translates the errors for a field from a keyword list of errors.

Link to this section Functions

Returns a formatted group of all flash messages available.

example

Example

<.flash_messages flash={conn.assigns.flash} />

attributes

Attributes

  • flash (:map)

Renders generic error message

attributes

Attributes

  • for (:string) - Defaults to nil.

slots

Slots

  • inner_block (required)

Renders a simple flash message tag

attributes

Attributes

  • flash_type (:string)
  • message (:string)

Renders a Torch form input with label and error messages.

A %Phoenix.HTML.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

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

attributes

Attributes

  • id (:any) - Defaults to nil.
  • type (:string) - Defaults to "text".
  • value (:any)
  • name (:any)
  • label (:string) - Defaults to nil.
  • field (Phoenix.HTML.FormField) - a form field struct retrieved from the form, for example: @form[:email].
  • errors (:list) - 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 Phoenix.HTML.Form.options_for_select/2.
  • multiple (:boolean) - the multiple flag for select inputs. Defaults to false. Global attributes are accepted.

slots

Slots

  • inner_block

Renders a label

attributes

Attributes

  • for (:string) - Defaults to nil.

slots

Slots

  • inner_block (required)

Translates an error message using gettext.

Link to this function

translate_errors(errors, field)

View Source

Translates the errors for a field from a keyword list of errors.