Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nil and "" values equally #444

Closed
jonatanklosko opened this issue Jun 24, 2024 · 0 comments
Closed

Handle nil and "" values equally #444

jonatanklosko opened this issue Jun 24, 2024 · 0 comments

Comments

@jonatanklosko
Copy link

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 "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant