View Source PetalComponents.Field (petal_components v1.2.0)
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.
Attributes
class
(:string
) - extra classes for the help text. Defaults to""
.help_text
(:string
) - context/help for your field. Defaults tonil
. Global attributes are accepted.
Slots
inner_block
Renders a label.
Attributes
class
(:string
) - Defaults tonil
.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 tonil
.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 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
.group_layout
(:string
) - 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 tonil
.wrapper_class
(:string
) - the wrapper div classes. Defaults tonil
.help_text
(:string
) - context/help for your field. Defaults tonil
. Global attributes are accepted.
Generates a generic error message.
slots
Slots
inner_block
(required)
attributes
Attributes
class
(:string
) - extra classes for the help text. Defaults to""
.help_text
(:string
) - context/help for your field. Defaults tonil
. Global attributes are accepted.
slots
Slots
inner_block
Renders a label.
attributes
Attributes
for
(:string
) - Defaults tonil
.class
(:string
) - Defaults tonil
. Global attributes are accepted.
slots
Slots
inner_block
(required)
attributes
Attributes
class
(:string
) - Defaults tonil
.errors
(:list
) - Defaults to[]
.name
(:string
) Global attributes are accepted.
slots
Slots
inner_block
(required)