formex v0.2.0 Formex.CustomField.SelectAssoc
This module generates a :select field with options downloaded from Repo.
Example of use for Article with one Category:
schema "articles" do
belongs_to :category, App.Category
end
form
|> add(Formex.CustomField.SelectAssoc, :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.
Options
choice_name- controls the content of<option>. May be the name of field or function. Example of use:form |> add(SelectAssoc, :article_id, label: "Article", choice_name: :title)form |> add(SelectAssoc, :article_id, label: "Article", choice_name: fn article -> article.title end)
Summary
Functions
Function that generates Formex.Field.t/0, similary to Formex.Field.create_field/4
Functions
Function that generates Formex.Field.t/0, similary to Formex.Field.create_field/4
Callback implementation for Formex.CustomField.create_field/3.