Skip to content

Commit 43a0752

Browse files
authored
Merge pull request #331 from scientist-softserv/329-dynamic-form-checkboxes
329 dynamic form checkboxes
2 parents a463bcf + 3dbc82e commit 43a0752

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

utils/api/configurations.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,19 @@ export const configureDynamicFormSchema = (defaultSchema) => {
277277
adjustedProperty = { ...remainingProperties }
278278
}
279279

280-
if (value.type !== 'array') {
281-
// TODO(alishaevn): figure out the "items" property for arrays
282-
// ref: https://react-jsonschema-form.readthedocs.io/en/v1.8.1/form-customization/#form-customization
280+
if (value.type === 'array') {
281+
let { title, type } = adjustedProperty
282+
283+
propertyFields[key] = {
284+
type,
285+
title,
286+
items: {
287+
type: 'string',
288+
enum: adjustedProperty.enum,
289+
},
290+
uniqueItems: true,
291+
}
292+
} else {
283293
propertyFields[key] = adjustedProperty
284294
}
285295
}
@@ -305,6 +315,7 @@ export const configureDynamicFormUiSchema = (schema, defaultOptions) => {
305315
if(fields[key].helper) fieldOptions['ui:help'] = fields[key].helper
306316
if(fields[key].placeholder) fieldOptions['ui:placeholder'] = fields[key].placeholder
307317
if(fields[key].type) fieldOptions['ui:inputType'] = fields[key].type
318+
if(fields[key].type === 'checkbox') fieldOptions['ui:widget'] = 'checkboxes'
308319
if(fields[key].rows) {
309320
fieldOptions['ui:options']= {
310321
widget: 'textarea',

utils/theme/globals.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ body {
2222

2323
footer {
2424
margin-top: auto;
25-
}
25+
}
26+
27+
.form-group.field-array .checkbox input {
28+
margin-right: 10px;
29+
}

0 commit comments

Comments
 (0)