Skip to content

Commit a4f612e

Browse files
jrcastro2kpsherva
authored andcommitted
arrayField: move label outside field
* closes zenodo/who-rdm#89
1 parent cb1ba08 commit a4f612e

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/lib/forms/ArrayField.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React, { Component } from "react";
99
import PropTypes from "prop-types";
1010
import { getIn, FieldArray } from "formik";
11-
import { Form, Icon } from "semantic-ui-react";
11+
import { Form, Icon, Button } from "semantic-ui-react";
1212
import _isEmpty from "lodash/isEmpty";
1313
import _filter from "lodash/filter";
1414
import _matches from "lodash/matches";
@@ -87,30 +87,32 @@ export class ArrayField extends Component {
8787
const { nextKey } = this.state;
8888
const valuesToDisplay = this.getValues(values, fieldPath);
8989
return (
90-
<Form.Field {...uiProps} {...hasError}>
91-
<FieldLabel htmlFor={fieldPath} icon={labelIcon} label={label} />
90+
<>
91+
<Form.Field {...uiProps} {...hasError}>
92+
<FieldLabel htmlFor={fieldPath} icon={labelIcon} label={label} />
9293

93-
{valuesToDisplay.map((value, index, array) => {
94-
const arrayPath = fieldPath;
95-
const indexPath = index;
96-
const key = value.__key || index;
94+
{valuesToDisplay.map((value, index, array) => {
95+
const arrayPath = fieldPath;
96+
const indexPath = index;
97+
const key = value.__key || index;
9798

98-
return (
99-
<div key={key}>
100-
{children({
101-
array,
102-
arrayHelpers,
103-
arrayPath,
104-
indexPath,
105-
key,
106-
value,
107-
...props,
108-
})}
109-
</div>
110-
);
111-
})}
99+
return (
100+
<div key={key}>
101+
{children({
102+
array,
103+
arrayHelpers,
104+
arrayPath,
105+
indexPath,
106+
key,
107+
value,
108+
...props,
109+
})}
110+
</div>
111+
);
112+
})}
113+
</Form.Field>
112114

113-
{helpText && <label className="helptext">{helpText}</label>}
115+
{helpText && <label className="helptext rel-mb-1">{helpText}</label>}
114116

115117
<Form.Group>
116118
<Form.Button

0 commit comments

Comments
 (0)