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

Form submit fails on attributes with the type 'number' #66

Open
dw2 opened this issue Feb 9, 2016 · 3 comments
Open

Form submit fails on attributes with the type 'number' #66

dw2 opened this issue Feb 9, 2016 · 3 comments

Comments

@dw2
Copy link

dw2 commented Feb 9, 2016

I'm attempting to use a select box to pick from an array of numbers with labels (i.e. [[1,'Once'], [2,'Twice'], ...]. However, since the attribute is set to 'number' in the model, this causes the form to fail. (Edit: more info below)

@dw2
Copy link
Author

dw2 commented Feb 9, 2016

Checked the log, which was going by too quickly to notice earlier. I get the error Uncaught Error: value not in set of provided options. I think this is because the number array is converted to strings when in the DOM. When the view reads these values later, it doesn't match the attribute, which is the number 2 instead of "2" as seen by the <option value="2">Twice</option> HTML.

@cdaringe
Copy link
Member

cdaringe commented Feb 9, 2016

hey @dw2!

it's actually doing a == vs. a ===, so i'm wondering if there's more than meets the eye. see here.

if you'd want to edit your node_modules/ampersand-select-view/ampersand-select-view.js and slap a debugger statement right around there, report back on this.options and value. these should be good clues to help us move along!

thx!

@dw2
Copy link
Author

dw2 commented Feb 9, 2016

@cdaringe thanks for the reply. You are correct that it does a loose comparison with == for array options, but for textvalue option arrays, it uses indexOf to find the value. The PR I just made will apply a loose comparison in both cases, as well as allow for mixed option sets.

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

2 participants