I'm new to Elixir. Currently using a Pheonix framework. I need to convert structs to list so I can use them in the select field.
In my user_controller.ex
I attempt to convert a struct to list, but the variable user_types_name
is always empty.
user_type_names = []
for user <- Accounts.list_user_types() do
user_type_names ++ [user.name]
end
While in form.html.eex
. For additional information
<%= inputs_for f, :user_type, fn cf -> %>
<%= label cf, :user_type %>
<%= select cf, :user_type, @user_type_names %>
<%= error_tag cf, :user_type %>
<% end %>