JediHelpers.FormHelpers (jedi_helpers v0.2.1)

Helper functions for form inputs and options.

Summary

Functions

Generates {label, id} tuples for a list of maps or structs to be used in dropdowns.

Functions

options_for(list, label_field)

Generates {label, id} tuples for a list of maps or structs to be used in dropdowns.

Examples

iex> users = [%{id: 1, name: "Alice"}, %{id: 2, name: "Bob"}]
iex> JediHelpers.FormHelpers.options_for(users, :name)
[{"Alice", 1}, {"Bob", 2}]

Raises if an element is not a map or struct, or if the arguments are invalid.