admin-on-rest-fr05t1k
Version:
A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI
19 lines (16 loc) • 712 B
JavaScript
import React from 'react';
import { Field } from 'redux-form';
import Labeled from '../input/Labeled';
const FormField = ({ input, ...rest }) => input.props.addField ?
(input.props.addLabel ?
<Field {...rest} {...input.props} name={input.props.source} component={Labeled} label={input.props.label}>{ input }</Field> :
<Field {...rest} {...input.props} name={input.props.source} component={input.type} />
) :
(input.props.addLabel ?
<Labeled {...rest} label={input.props.label} source={input.props.source}>{input}</Labeled> :
(typeof input.type === 'string' ?
input :
React.cloneElement(input, rest)
)
);
export default FormField;