The book uses this code in the age group filter:
<form phx-change="age_group_filter" phx-target="<%= @myself%>">
<label>Filter by age group:</label>
<select name="age_group_filter" id="age_group_filter">
<%= for age_group <-
["all", "18 and under", "18 to 25", "25 to 35", "35 and up"] do %>
<option
value="<%= age_group %>"
<%=if @age_group_filter == age_group, do: "selected" %> >
<%=age_group%>
</option>
<% end %>
</select>
</form>
But I think that there is a more elegant way to do this:
<%= f = form_for :age_group, "#", [phx_change: :age_group_change, phx_target: @myself] %>
<%= select f, :age_group_filter,
["all", "18 and under", "18 to 25", "25 to 35", "35 and up"],
selected: @age_group_filter
%>
</form>