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() {
let field = null;
if (this.props.readOnly) {
field = this.getReadonlyField;
field = this.getReadonlyField();
} else {
field = this.getSelectField();
}
@ -28,9 +28,10 @@ class SingleSelectField extends SilverStripeComponent {
* @returns ReactComponent
*/
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
: this.props.value;