SigmaKit.Components.Forms (sigma_kit v0.0.16)
Summary
Functions
Slots
inner_block
(required)
Renders an input with label and error messages.
Renders a label.
Renders a simple form.
Translates an error message using gettext.
Translates the errors for a field from a keyword list of errors.
Functions
Slots
inner_block
(required)
Renders an input with label and error messages.
A Phoenix.HTML.FormField
may be passed as argument,
which is used to retrieve the input name, id, and values.
Otherwise all attributes may be passed explicitly.
Examples
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
Attributes
id
(:any
) - the id of the input. Defaults tonil
.name
(:any
) - the name of the input.label
(:string
) - the label for the input. Defaults tonil
.value
(:any
) - the value of the input.type
(:string
) - the type of the 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 strings to display as field errors. Defaults to[]
.checked
(:boolean
) - the checked flag for checkbox inputs.prompt
(:string
) - the prompt for select inputs. Defaults tonil
.options
(:list
) - the options to pass to Phoenix.HTML.Form.options_for_select/2.multiple
(:boolean
) - the multiple flag for select inputs. Defaults tofalse
.- Global attributes are accepted. Supports all globals plus:
["accept", "autocomplete", "capture", "cols", "disabled", "form", "list", "max", "maxlength", "min", "minlength", "multiple", "pattern", "placeholder", "readonly", "required", "rows", "size", "step"]
.
Slots
help
- A slot used to display help text under the input.
Renders a label.
Attributes
for
(:string
) - Defaults tonil
.
Slots
inner_block
(required)
Renders a simple form.
Examples
<.simple_form for={@form} phx-change="validate" phx-submit="save">
<.input field={@form[:email]} label="Email"/>
<.input field={@form[:username]} label="Username" />
<:actions>
<.button>Save</.button>
</:actions>
</.simple_form>
Attributes
for
(:any
) (required) - the data structure for the form.as
(:any
) - the server side parameter to collect all input under. Defaults tonil
.- Global attributes are accepted. the arbitrary HTML attributes to apply to the form tag. Supports all globals plus:
["autocomplete", "name", "rel", "action", "enctype", "method", "novalidate", "target", "multipart"]
.
Slots
inner_block
(required)actions
- the slot for form actions, such as a submit button.
Translates an error message using gettext.
Translates the errors for a field from a keyword list of errors.