Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport ISO dates fix in volto-form-block #834

Merged
merged 1 commit into from
Dec 20, 2024
Merged
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
19 changes: 10 additions & 9 deletions src/customizations/volto-form-block/components/View.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// CUSTOMIZATION:
// - added warning state to form
// - backport for https://github.com/collective/volto-form-block/pull/122

import React, { useState, useEffect, useReducer, useRef } from 'react';
import { useSelector, useDispatch } from 'react-redux';
Expand All @@ -8,7 +9,6 @@ import { useIntl, defineMessages } from 'react-intl';
import { submitForm, resetOTP } from 'volto-form-block/actions';
import { getFieldName } from 'volto-form-block/components/utils';
import FormView from 'volto-form-block/components/FormView';
import { formatDate } from '@plone/volto/helpers/Utils/Date';
import config from '@plone/volto/registry';
import { Captcha } from 'volto-form-block/components/Widget';
import { isValidEmail } from 'volto-form-block/helpers/validators';
Expand Down Expand Up @@ -260,20 +260,21 @@ const View = ({ data, id, path }) => {
config.blocks.blocksConfig.form.attachment_fields.includes(
subblock.field_type,
);
const isDate = subblock.field_type === 'date';
// const isDate = subblock.field_type === 'date';

if (isAttachment) {
attachments[name] = formattedFormData[name].value;
delete formattedFormData[name];
}

if (isDate) {
formattedFormData[name].value = formatDate({
date: formattedFormData[name].value,
format: 'DD-MM-YYYY',
locale: intl.locale,
});
}
// XXX: dates should be sent as ISO format, not DD-MM-YYYY !
// if (isDate) {
// formattedFormData[name].value = formatDate({
// date: formattedFormData[name].value,
// format: 'DD-MM-YYYY',
// locale: intl.locale,
// });
// }
}
});
dispatch(
Expand Down
Loading