2016-05-28 05:05:27 +08:00
|
|
|
import React from 'react';
|
|
|
|
|
|
|
|
const FormField = (props) => {
|
|
|
|
return (
|
|
|
|
<span>
|
2016-07-01 04:38:42 +08:00
|
|
|
<label htmlFor={props.field}>{props.title}:</label>
|
2016-05-28 05:05:27 +08:00
|
|
|
<input
|
|
|
|
type={props.type || "text"}
|
|
|
|
id={props.field}
|
|
|
|
style={props.style}
|
|
|
|
className={(props.accountInfo[props.field] && props.errorFieldNames.includes(props.field)) ? 'error' : ''}
|
|
|
|
disabled={props.submitting}
|
|
|
|
value={props.accountInfo[props.field] || ''}
|
|
|
|
onKeyPress={props.onFieldKeyPress}
|
|
|
|
onChange={props.onFieldChange}
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
FormField.propTypes = {
|
|
|
|
field: React.PropTypes.string,
|
|
|
|
title: React.PropTypes.string,
|
|
|
|
type: React.PropTypes.string,
|
|
|
|
style: React.PropTypes.object,
|
|
|
|
submitting: React.PropTypes.bool,
|
|
|
|
onFieldKeyPress: React.PropTypes.func,
|
|
|
|
onFieldChange: React.PropTypes.func,
|
|
|
|
errorFieldNames: React.PropTypes.array,
|
|
|
|
accountInfo: React.PropTypes.object,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FormField;
|