Handle `nil` and `""` values equally
jonatanklosko opened this issue · comments
Jonatan Kłosko commented
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 ""
.