phoenixframework / phoenix_html

Building blocks for working with HTML in Phoenix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle `nil` and `""` values equally

jonatanklosko opened this issue · comments

Phoenix.HTML.Form.options_for_select([x: "x", empty: ""], "")
#=> <option value="x">x</option>
#=> <option selected value="">empty</option>

# vs

Phoenix.HTML.Form.options_for_select([x: "x", empty: ""], nil)
#=> <option value="x">x</option>
#=> <option value="">empty</option>

This discrepancy comes from the fact that we use html_escape to normalize values, and it it's different for nil and "".