defmodule MyApp.MyDomain.SomeEnum do
use Ash.Type.Enum, values: [:foo, :bar, :blah]
def label_for(category) do
category
|> Atom.to_string()
|> String.capitalize()
end
@doc """
Returns a list suitable for passing to `MyAppWeb.CoreComponents.input/1` when
`type=select`.
"""
def options_for_select do
for category <- values() do
{label_for(category), category}
end
end
end
defmodule MyApp.MyDomain.SomeEnum do
use Ash.Type.Enum, values: [:foo, :bar, :blah]
def label_for(category) do
category
|> Atom.to_string()
|> String.capitalize()
end
@doc """
Returns a list suitable for passing to `MyAppWeb.CoreComponents.input/1` when
`type=select`.
"""
def options_for_select do
for category <- values() do
{label_for(category), category}
end
end
end