{ this.props.prefix ?
{this.props.prefix} : '' }
{ renderElementInsideLabel ?
:
element }
{ this.props.postfix ?
{this.props.postfix} : '' }
{ isError && this.state.errorMessage ?
{this.state.errorMessage}
: '' }
}
}
export class FormRow extends React.Component {
static propTypes = {
label: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.element]),
// helper: React.PropTypes.html,
}
constructor(props) {
super(props);
this._fieldRequiredText = 'This field is required';
this.state = {
isError: false,
errorMessage: null,
};
}
showError(text) {
this.setState({
isError: true,
errorMessage: text,
});
}
showRequiredError() {
this.showError(this._fieldRequiredText);
}
clearError(text) {
this.setState({
isError: false,
errorMessage: ''
});
}
getValue() {
return this.refs.field.getValue();
}
getSelectedElement() {
return this.refs.field.getSelectedElement();
}
focus() {
this.refs.field.focus();
}
render() {
const fieldProps = Object.assign({}, this.props),
elementId = formFieldId(),
renderLabelInFormField = formFieldNestedLabelTypes.includes(this.props.type);
if (!renderLabelInFormField) {
delete fieldProps.label;
}
delete fieldProps.helper;
return
{ this.props.label && !renderLabelInFormField ?
: '' }
{ !this.state.isError && this.props.helper ?
{this.props.helper}
: '' }
{ this.state.isError ?
{this.state.errorMessage}
: '' }
}
}