Skip to content

Commit b5fd610

Browse files
committed
Fix field types for number and time fields.
Fix values passing to checkbox wrapper.
1 parent 4944c2d commit b5fd610

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ 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 } from 'lodash';
11+
import { includes, keys, map, pickBy, without, isObject } from 'lodash';
1212
import { Grid, Message } from 'semantic-ui-react';
1313
import config from '@plone/volto/registry';
1414
import { renderToString } from 'react-dom/server';
@@ -77,6 +77,23 @@ const FormBlockView = ({ data, id, properties, metadata, path }) => {
7777
),
7878
);
7979

80+
map(keys(submitData), (field) => {
81+
if (
82+
data.schema.properties[field].factory === 'number' &&
83+
submitData[field] !== undefined
84+
) {
85+
submitData[field] = parseInt(submitData[field]);
86+
}
87+
88+
if (
89+
data.schema.properties[field].factory === 'time' &&
90+
isObject(submitData[field])
91+
) {
92+
submitData[field] =
93+
`${submitData[field].hour}:${submitData[field].minute}`;
94+
}
95+
});
96+
8097
dispatch(submitForm(path, id, submitData, captcha))
8198
.then((resp) => {
8299
setSubmitted(true);

frontend/packages/volto-form-block/src/schemaFormBlock/Wrappers/CheckboxWrapper.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ const CheckboxWrapper = (props) => {
3737
value={value || ''}
3838
label={title}
3939
description={description}
40+
default={props.default}
4041
isRequired={required}
4142
labelRequired={intl.formatMessage(messages.required)}
4243
disabled={isDisabled}
4344
onChange={(value) => onChange(id, value === '' ? undefined : value)}
4445
ref={ref}
4546
onClick={() => onClick()}
4647
errorMessage={error ? error[0] : ''}
47-
isInvalid={error}
48+
isInvalid={error !== undefined}
4849
/>
4950
</FormFieldWrapper>
5051
);

0 commit comments

Comments
 (0)