Closed dhritzkiv closed 10 years ago
After digging through the code, I believe I have found the culprit.
The relevant logic in the validation (https://github.com/AmpersandJS/ampersand-select-view/blob/master/ampersand-select-view.js#L205):
//If it's a collection, ensure it's in the collection
if (this.options.isCollection) {
return this.options.indexOf(this.value) > -1;
}
The above code doesn't return true
when the yieldModel
option is set to false
because the yielded string value doesn't exist in the options array.
Something like this may work better:
if (this.options.isCollection) {
if (!this.yieldModel) {
return !!this.options.get(this.value, this.idAttribute);
}
return this.options.indexOf(this.value) > -1;
}
Thoughts?
Hi @dhritzkiv, sorry about that! It would seem I fixed this, but forgot to actually push & publish it!
Now published as 1.0.2 and fixed here: https://github.com/AmpersandJS/ampersand-select-view/commit/4e4c5a582a3a57096e5afeb7f123b691d2d0371b
Perfect. Thanks!
On Jul 12, 2014, at 13:03, Philip Roberts notifications@github.com wrote:
Hi @dhritzkiv, sorry about that! It would seem I fixed this, but forgot to actually push & publish it!
Now published as 1.0.2 and fixed here: 4e4c5a5
— Reply to this email directly or view it on GitHub.
Passing a collection of options and choosing a default value still makes the field return
false
for validity.Options:
In situ:
Asking for a value from the DOM explicitly:
Any idea what may be causing this? Let me know if you need more information.