Description
Version: vue-form-generator 2.0.0-beta.15
Scenario:
Copy pasted the example from https://icebob.gitbooks.io/vueformgenerator/content/fields/vuemultiselect.html (simple object select)
Result:
In the select list option I get the whole objects including their fields
Expected:
In the select list options I have only text values according to the label
prop I have set.
In this case, only name
should be shown (Vue.js, Rails, Sinatra) just the same as in the official vue multi select docs. http://monterail.github.io/vue-multiselect/#sub-single-select-object
Cause:
It seems that customLabel
function from the fieldMultiSelect has some wrong logic in it:
customLabel(){
if (typeof this.schema.selectOptions !== "undefined" && typeof this.schema.selectOptions.customLabel !== "undefined" && this.schema.selectOptions.customLabel === "function") {
return this.schema.selectOptions.customLabel;
} else {
return function(currentLabel){return currentLabel;};
}
}
This bit return function(currentLabel){return currentLabel;};
returns the whole object instead of returning the necessary label only. Also a specified customLabel
function doesn't work because of this check this.schema.selectOptions.customLabel === "function"
which has a missing typeof
before it.
Here is an alternative:
customLabel(){
if (typeof this.schema.selectOptions !== "undefined" && typeof this.schema.selectOptions.customLabel !== "undefined" && typeof this.schema.selectOptions.customLabel === "function") {
return this.schema.selectOptions.customLabel;
} else {
return undefined;
}
}
Since the vue-multiselect library has it's own way of handling default values why not pass an undefined
to it when there is no customLabel
provided by the user and let the library handle it's stuff?