Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/FormBuilder/FormBuilder.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,13 @@ const FormFieldSet = ({
const isFormInline = formInline && field?.type !== 'component'
if (field) {
const err = get(formik.touched, layout) && get(formik.errors, layout);
const errText = Array.isArray(err) ? Array.from(new Set(err)).join(', ') : err;
const isErrArrString = Array.isArray(err) ? err?.reduce((acc, curr) => {
return acc || (typeof curr === 'string' || curr instanceof String)
}, false): false;

const isErrString = isErrArrString || (typeof err === 'string' || err instanceof String)

const growFactor = ((field.forceColumnWidth ?? 0) === 0) ? {} : { sm: field.forceColumnWidth }
return (
<Grid
Expand All @@ -867,7 +874,7 @@ const FormFieldSet = ({
>
{renderField(layout, field, fieldName)}
<FormHelperText>
{!Array.isArray(err) ? err : ""}
{isErrString ? errText: ""}
</FormHelperText>
</FormControl>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/FormBuilder/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,9 @@ Duration.args = {
duration: {
type: "duration",
label: "Duration",
initialValues: 60400,
initialValues: '',
validator: () =>
Yup.number().required().nullable()
Yup.number().required().label()
},
},
formId: "duration",
Expand Down