View Source Torch.Component (Torch v5.2.0)

Provides Phoenix.Components for use in Torch views and layouts

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.

Functions

Link to this function

flash_messages(assigns)

View Source (since 5.0.0)

Returns a formatted group of all flash messages available.

Example

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

Attributes

  • flash (:map)
Link to this function

torch_error(assigns)

View Source (since 5.0.0)

Renders generic error message

Attributes

  • for (:string) - Defaults to nil.

Slots

  • inner_block (required)
Link to this function

torch_flash(assigns)

View Source (since 5.0.0)

Renders a simple flash message tag

Attributes

  • flash_type (:string)
  • message (:string)
Link to this function

torch_input(assigns)

View Source (since 5.0.0)

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

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

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. Supports all globals plus: ["autocomplete", "cols", "disabled", "form", "max", "maxlength", "min", "minlength", "pattern", "placeholder", "readonly", "required", "rows", "size", "step"].

Slots

  • inner_block
Link to this function

torch_label(assigns)

View Source (since 5.0.0)

Renders a label

Attributes

  • for (:string) - Defaults to nil.

Slots

  • inner_block (required)
Link to this function

translate_error(arg)

View Source (since 5.0.0)

Translates an error message using gettext.

Link to this function

translate_errors(errors, field)

View Source (since 5.0.0)

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