Pax.Field.Components (Pax v0.0.1-dev)
View SourceSummary
Functions
Renders an input control for the given field and form_field. This is for use by Pax.Field implementations. As such, it requires a field and form_field, and will render the appropriate input control for the field type.
Renders a single field error.
Renders a list of errors for the given Pax.Field. The errors are rendered using the <.pax_field_error>
component.
Renders an input control for the given field and form, as well as any errors for the field. The input control is
determined by the field type, as the type's input/3
is called, which will render the appropriate input control for
the field type. The errors are rendered using the pax_field_errors/1
function, which will render any errors for the
field.
Renders a field input or text for the given Pax.Field. If the field is immutable, or if no form is set, then a
<.pax_field_text class={@text_class} ...>
is rendered. Otherwise, a <.pax_field_input class={@input_class} ...>
is rendered.
Renders a label for the given Pax.Field. If the Pax.Field has a :label
option set, it will be used as the label text,
otherwise the field name will be used. The :for
option can be used to set the for
attribute of the label, otherwise
the :form
will be used if set, and finally the field name will be used.
Renders a link for the given Pax.Field, similar to pax_field_text/1
, but wrapped in a <.pax_link>
component. The
link will use the navigate
attribute, which results in patches to the same LiveView, navigates to different
LiveViews in the same live_session
, and finally a normal, full page navigation to other URLs.
Renders a link or text for the given Pax.Field. A link is rendered if the field has a valid :link
option set.
Renders the :value
of the given Pax.Field as plain text. The field's value will be resolved depending on what it
is set to, calling any functions or using any other field names as required. Otherwise it will find the value in the
object
map by the field name. A nil
value will be rendered as a unicode bullet character (•
, U+2022).
Functions
Renders an input control for the given field and form_field. This is for use by Pax.Field implementations. As such, it requires a field and form_field, and will render the appropriate input control for the field type.
The form_field is used to retrieve the input name, id and values, however they can be overridden by passing them explicitly.
Types
This function accepts all HTML input types, considering that:
- You may also set
type="select"
to render a<select>
tag type="checkbox"
is used exclusively to render boolean values- For live file uploads, see
Phoenix.Component.live_file_input/1
See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input for more information.
Examples
<.input field={@form[:email]} type="email" />
<.input name="my-input" errors={["oh no!"]} />
Attributes
field
(:any
) (required)form_field
(Phoenix.HTML.FormField
)id
(:any
) - Defaults tonil
.name
(:any
)label
(:string
) - Defaults tonil
.value
(:any
)has_errors
(:boolean
) - Defaults tofalse
.type
(:string
) - Defaults to"text"
. Must be one of"checkbox"
,"color"
,"date"
,"datetime-local"
,"email"
,"file"
,"hidden"
,"month"
,"number"
,"password"
,"range"
,"radio"
,"search"
,"select"
,"tel"
,"text"
,"textarea"
,"time"
,"url"
, or"week"
.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
.true_value
(:string
) - the value to display for true checkboxes. Defaults to"True"
.false_value
(:string
) - the value to display for false checkboxes. Defaults to"False"
.- 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"]
.
Renders a single field error.
Attributes
class
(:any
) - Defaults tonil
.
Slots
inner_block
(required)
Renders a list of errors for the given Pax.Field. The errors are rendered using the <.pax_field_error>
component.
Attributes
errors
(:list
)field
(:any
) (required)form
(:any
) - Defaults tonil
.class
(:any
) - Defaults tonil
.error_class
(:string
) - Defaults tonil
.
Renders an input control for the given field and form, as well as any errors for the field. The input control is
determined by the field type, as the type's input/3
is called, which will render the appropriate input control for
the field type. The errors are rendered using the pax_field_errors/1
function, which will render any errors for the
field.
Attributes
field
(:any
) (required)form
(:any
) (required)object
(:any
) (required)class
(:any
) - Defaults tonil
.text_class
(:any
) - Defaults tonil
.errors_class
(:any
) - Defaults tonil
.error_class
(:any
) - Defaults tonil
.
Renders a field input or text for the given Pax.Field. If the field is immutable, or if no form is set, then a
<.pax_field_text class={@text_class} ...>
is rendered. Otherwise, a <.pax_field_input class={@input_class} ...>
is rendered.
Attributes
field
(:any
) (required)form
(:any
) - Defaults tonil
.object
(:any
) (required)input_class
(:any
) - Defaults tonil
.text_class
(:any
) - Defaults tonil
.errors_class
(:any
) - Defaults tonil
.error_class
(:any
) - Defaults tonil
.
Renders a label for the given Pax.Field. If the Pax.Field has a :label
option set, it will be used as the label text,
otherwise the field name will be used. The :for
option can be used to set the for
attribute of the label, otherwise
the :form
will be used if set, and finally the field name will be used.
Attributes
field
(:any
) (required)form
(:any
) - Defaults tonil
.label
(:string
) - Defaults tonil
.for
(:string
) - Defaults tonil
.class
(:any
) - Defaults tonil
.
Renders a link for the given Pax.Field, similar to pax_field_text/1
, but wrapped in a <.pax_link>
component. The
link will use the navigate
attribute, which results in patches to the same LiveView, navigates to different
LiveViews in the same live_session
, and finally a normal, full page navigation to other URLs.
Attributes
field
(:any
) (required)object
(:map
) (required)link
(:string
) (required)class
(:any
) - Defaults tonil
.
Renders a link or text for the given Pax.Field. A link is rendered if the field has a valid :link
option set.
If the field has a link set, then this turns into <.pax_field_link class={@link_class} link={link}>...</.pax_field_link>
.
If the field does not have a link set, then this turns into <.pax_field_text class={@text_class}>...</.pax_field_text>
.
Attributes
field
(:any
) (required)object
(:map
) (required)link_class
(:string
) - Defaults tonil
.text_class
(:string
) - Defaults tonil
.
Renders the :value
of the given Pax.Field as plain text. The field's value will be resolved depending on what it
is set to, calling any functions or using any other field names as required. Otherwise it will find the value in the
object
map by the field name. A nil
value will be rendered as a unicode bullet character (•
, U+2022).
Attributes
field
(:any
) (required)object
(:map
) (required)class
(:any
) - Defaults tonil
.