Get the Values for a Ecto Schema Enum Column
I recently started learning Elixir and had a model with an enum column with the following attributes:
In my view, I had a form object where I wanted to have a select input with the values from my enum column, form_factor
. Luckily, the Ecto.Enum
module has a few functions that can help with this - mappings/2
, values/2
, and dump_values/2
.
I ended up using the following in my form:
https://hexdocs.pm/ecto/Ecto.Enum.html
Tweet