Skip to content

Commit

Permalink
fix #1301
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed May 13, 2017
1 parent ba71655 commit face547
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ const editor = function(editable, attr, format, editorClass, defaultValue, ignor
let options = [];
const values = editable.options.values;
if (Array.isArray(values)) {// only can use arrray data for options
let rowValue;
options = values.map((d, i) => {
rowValue = format ? format(d) : d;
let text;
let value;
options = values.map((option, i) => {
if (typeof option === 'object') {
text = option.text;
value = option.value;
} else {
text = format ? format(option) : option;
value = option;
}
return (
<option key={ 'option' + i } value={ d }>{ rowValue }</option>
<option key={ 'option' + i } value={ value }>{ text }</option>
);
});
}
Expand Down

0 comments on commit face547

Please sign in to comment.