Skip to content

Commit

Permalink
Add example of selecting multiple options in options_for_select
Browse files Browse the repository at this point in the history
  • Loading branch information
Gazler committed Sep 13, 2023
1 parent d2e4b5d commit f776666
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/phoenix_html/form.ex
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,17 @@ defmodule Phoenix.HTML.Form do
## Examples
options_for_select(["Admin": "admin", "User": "user"], "admin")
#=> <option value="admin" selected="selected">Admin</option>
#=> <option value="admin" selected>Admin</option>
#=> <option value="user">User</option>
Multiple selected values:
options_for_select(["Admin": "admin", "User": "user", "Moderator": "moderator"],
["admin", "moderator"])
#=> <option value="admin" selected>Admin</option>
#=> <option value="user" >User</option>
#=> <option value="moderator" selected>Moderator</option>
Groups are also supported:
options_for_select(["Europe": ["UK", "Sweden", "France"], ...], nil)
Expand Down

0 comments on commit f776666

Please sign in to comment.