committed by
Stuart Taylor
parent
bd40601305
commit
ae37a2caed
@ -48,6 +48,7 @@ function DynamicForm({
|
|||||||
<FormFields
|
<FormFields
|
||||||
errors={ errors }
|
errors={ errors }
|
||||||
fields={ fields }
|
fields={ fields }
|
||||||
|
formId={ id }
|
||||||
options={ options }
|
options={ options }
|
||||||
/>
|
/>
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@ const propTypes = {
|
|||||||
value: PropTypes.string.isRequired
|
value: PropTypes.string.isRequired
|
||||||
})
|
})
|
||||||
).isRequired,
|
).isRequired,
|
||||||
|
formId: PropTypes.string,
|
||||||
options: PropTypes.shape({
|
options: PropTypes.shape({
|
||||||
errors: PropTypes.objectOf(
|
errors: PropTypes.objectOf(
|
||||||
PropTypes.oneOfType([
|
PropTypes.oneOfType([
|
||||||
@ -34,7 +35,7 @@ const propTypes = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function FormFields(props) {
|
function FormFields(props) {
|
||||||
const { errors = {}, fields, options = {} } = props;
|
const { errors = {}, fields, formId, options = {} } = props;
|
||||||
const {
|
const {
|
||||||
ignored = [],
|
ignored = [],
|
||||||
placeholder = true,
|
placeholder = true,
|
||||||
@ -48,7 +49,9 @@ function FormFields(props) {
|
|||||||
.filter(field => !ignored.includes(field))
|
.filter(field => !ignored.includes(field))
|
||||||
.map(key => fields[key])
|
.map(key => fields[key])
|
||||||
.map(({ name, onChange, value, pristine }) => {
|
.map(({ name, onChange, value, pristine }) => {
|
||||||
const key = _.kebabCase(name);
|
const key = formId ?
|
||||||
|
`${formId}_${_.kebabCase(name)}` :
|
||||||
|
_.kebabCase(name);
|
||||||
const type = name in types ? types[name] : 'text';
|
const type = name in types ? types[name] : 'text';
|
||||||
return (
|
return (
|
||||||
<Row className='inline-form-field' key={ key }>
|
<Row className='inline-form-field' key={ key }>
|
||||||
|
Reference in New Issue
Block a user