smpallen99 / ex_admin

ExAdmin is an auto administration package for Elixir and the Phoenix Framework
MIT License
1.2k stars 272 forks source link

Selection field on Form #422

Closed cdesch closed 6 years ago

cdesch commented 6 years ago

If I have a field that takes a numerical input, like 0, 1, 3... but want to assign a friendly string to it, how do I get the selection box to show the label?

I know I can add a selection box like this:

     input user, :role, [collection: ~w(0 1 2) ] 

Although, how do I get each of those values to show on the webpage as Customer, Moderator, Admin instead of as 0, 1, 2

cdesch commented 6 years ago

I was able to get it to work with the code from issue #91

Here is the working code:

    input user, :role, collection: [{0, "Customer"}, {1, "Moderator"}, {3, "Admin"}]