Fix SingleSelectField readonly view

This commit is contained in:
Ingo Schommer 2016-09-06 20:40:14 +12:00
parent 1d3aaf368e
commit f7f1cf0e87

View File

@ -14,7 +14,7 @@ class SingleSelectField extends SilverStripeComponent {
render() { render() {
let field = null; let field = null;
if (this.props.readOnly) { if (this.props.readOnly) {
field = this.getReadonlyField; field = this.getReadonlyField();
} else { } else {
field = this.getSelectField(); field = this.getSelectField();
} }
@ -28,9 +28,10 @@ class SingleSelectField extends SilverStripeComponent {
* @returns ReactComponent * @returns ReactComponent
*/ */
getReadonlyField() { getReadonlyField() {
let label = this.props.source.find((item) => item.value === this.props.value); let label = this.props.source
&& this.props.source.find((item) => item.value === this.props.value);
label = label !== undefined label = typeof label === 'string'
? label ? label
: this.props.value; : this.props.value;