import React from 'react'; import {Icon} from './common.js'; var formFieldCounter = 0, formFieldNestedLabelTypes = ['radio', 'checkbox']; function formFieldId() { return "form-field-" + (++formFieldCounter); } export let FormField = React.createClass({ _fieldRequiredText: 'This field is required', _type: null, _element: null, propTypes: { type: React.PropTypes.string.isRequired, prefix: React.PropTypes.string, postfix: React.PropTypes.string, hasError: React.PropTypes.bool }, getInitialState: function() { return { isError: null, errorMessage: null, } }, componentWillMount: function() { if (['text', 'number', 'radio', 'checkbox', 'file'].includes(this.props.type)) { this._element = 'input'; this._type = this.props.type; } else if (this.props.type == 'text-number') { this._element = 'input'; this._type = 'text'; } else { // Non field, e.g.