Phoenix Select Form Helper
The select
form helper allows you to easily add a select input to your forms.
Among the types of arguments that the select
helper can accept are two-item tuples. The first item in the tuple is used as the label for the option and the second item is used as the value for the option.
Media.list_books
returns a list of structs representing all of the books in the database. We'll need to get from a list of structs to a list of tuples.
To do that, we'll pipe the list of Book
structs to Enum.map
and use an anonymous function to generate two-value tuples from those structs.