formex v0.4.15 Formex.Form

Summary

Types

t()
t() :: %Formex.Form{changeset: term, items: term, model: term, opts: term, params: term, phoenix_form: term, struct: term, template: term, template_options: term, type: term}

Functions

__struct__()

Defines the Formex.Form struct.

  • :type - the module that implements Formex.Type, for example: App.ArticleType
  • :struct - the struct that will be used in Ecto.Changeset.cast, for example: %App.Article{}
  • :model - struct.__struct__, for example: App.Article
  • :items - list of Formex.Field and Formex.Button structs
  • :params - params that will be used in Ecto.Changeset.cast
  • :changeset - %Ecto.Changeset{}
  • :phoenix_form - %Phoenix.HTML.Form{}
  • :template - the module that implements Formex.Template, for example: Formex.Template.BootstrapHorizontal. Can be set via a Formex.View.formex_form_for options
  • :opts - additional data passed in a controller. See: Formex.Builder.create_form/5
create_subform(form, type, name, opts \\ [])
create_subform(form :: Formex.Form.t, type :: any, name :: Atom.t, opts :: Map.t) :: Formex.Form.t

Creates a form for assoc.

Example:

form
|> add_form(:user_info, App.UserInfoType)

Options

get_fields(form)
get_fields(form :: t) :: list

Returns list of Formex.Field.t/0

get_subforms(form)
get_subforms(form :: t) :: list

Returns list of Formex.FormNested.t/0 and Formex.FormCollection.t/0

put_item(form, item)
put_item(form :: t, item :: any) :: t

Adds field to the form. More: Formex.Field.create_field/4, Formex.Button.create_button/3