render() {
let html;
let defaultValue = this.props.defaultValue;
- let options = this.props.options.map(function(op, i) {
+ let options = this.props.options && this.props.options.map(function(op, i) {
let value;
let label;
if(typeof(op) == 'object') {
}
return <option key={i} value={JSON.stringify(value)}>{label}</option>
- });
+ }) || [];
if (this.props.initial) {
options.unshift(<option key='blank' value={JSON.stringify(this.props.defaultValue)}></option>);
}
html = (
- <label key={this.props.key}>
+ <label key={this.props.key} className={this.props.className}>
{this.props.label}
- <select className={this.props.className} onChange={this.handleOnChange} defaultValue={JSON.stringify(defaultValue)} >
- {
- options
- }
- </select>
+ {
+ this.props.readonly ? defaultValue
+ : (
+ <select
+ className={this.props.className}
+ onChange={this.handleOnChange}
+ value={JSON.stringify(this.props.value)}
+ defaultValue={JSON.stringify(defaultValue)}>
+ {
+ options
+ }
+ </select>
+ )
+ }
</label>
);
return html;
console.log(e.target.value)
console.dir(e)
},
+ readonly: false,
/**
* Selected or default value