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

Submitting forms with empty selects yields 'null' string literal #73

Open
jadefish opened this issue Dec 10, 2018 · 0 comments
Open

Submitting forms with empty selects yields 'null' string literal #73

jadefish opened this issue Dec 10, 2018 · 0 comments

Comments

@jadefish
Copy link
Collaborator

If a form contains a <select> with no <option> elements, submitting the form yields a corresponding key-value pair with a string literal 'null' value. Non-empty selects and empty non-select elements yield the empty string.

Example:

form do
  select name: :select1 do
    label 'Select1'

    # first item selected by default:
    some_array.each_with_index do |item, i|
      option text: item, value: i
    end
  end

  select name: :select2 do
    label 'Select2'

    # no options:
    [].each_with_index do |item, i|
      option text: item, value: i
    end
  end

  button 'Submit' do
    creates some_path, redirect: some_other_path
  end
end

Submitting the above form yields:

select1: 0
select2: "null"
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