formex v0.1.4 Formex.Field
Summary
Types
Functions
Defines the Formex.Field struct.
:name
- a field name, for example::title
:type
- type of field that in most cases will be name of function fromPhoenix.HTML.Form
:value
- the value from struct/params:required
- is field required?:label
- the text label:data
- additional data used by particular field type (eg.:select_assoc
stores here data for<option>
’s):opts
- options
Creates a new field.
type
is, in most cases, the name of function from Phoenix.HTML.Form
. For now the only
exception is the :select_assoc
Custom types
:select_assoc
- creates standard:select
, but also downloads list of options from Repo. Example of use for Article with one Category:schema "articles" do belongs_to :category, App.Category end
form |> add(:select_assoc, :category_id, label: "Category")
Formex will find out that
:category_id
refers to App.Category schema and download all rows from Repo ordered by name. It assumes that Category has field calledname
Options
:label
:required
- defaults to true:phoenix_opts
- options that will be passed toPhoenix.HTML.Form
, for example:form |> add(:textarea, :content, phoenix_opts: [ rows: 4 ])