Skip to content

Commit cc0b986

Browse files
committed
Fix ordering of fields on submit.
1 parent 4e2edbd commit cc0b986

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

frontend/packages/volto-form-block/src/schemaFormBlock/ViewSchemaForm.jsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ import { toast } from 'react-toastify';
88
import { Toast } from '@plone/volto/components';
99
import { useLocation } from 'react-router-dom';
1010
import qs from 'query-string';
11-
import { includes, keys, map, pickBy, without, isObject } from 'lodash';
11+
import {
12+
flatten,
13+
includes,
14+
keys,
15+
map,
16+
pickBy,
17+
without,
18+
isObject,
19+
fromPairs,
20+
} from 'lodash';
1221
import { Grid, Message } from 'semantic-ui-react';
1322
import config from '@plone/volto/registry';
1423
import { renderToString } from 'react-dom/server';
@@ -94,6 +103,15 @@ const FormBlockView = ({ data, id, properties, metadata, path }) => {
94103
}
95104
});
96105

106+
// Order fields based on schema
107+
submitData = fromPairs(
108+
flatten(
109+
map(data.schema.fieldsets, (fieldset) =>
110+
map(fieldset.fields, (field) => [field, submitData[field]]),
111+
),
112+
),
113+
);
114+
97115
dispatch(submitForm(path, id, submitData, captcha))
98116
.then((resp) => {
99117
setSubmitted(true);

0 commit comments

Comments
 (0)