mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
parent
8970159ffa
commit
9ad9fafd6b
@ -60,6 +60,7 @@ function InputDate(props) {
|
||||
target: {
|
||||
name: props.name,
|
||||
value: moment,
|
||||
type: 'date',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ class InputToggleWithErrors extends React.Component {
|
||||
InputToggleWithErrors.defaultProps = {
|
||||
autoFocus: false,
|
||||
className: '',
|
||||
customBootstrapClass: 'col-md-6',
|
||||
customBootstrapClass: 'col-md-4',
|
||||
deactivateErrorHighlight: false,
|
||||
didCheckErrors: false,
|
||||
disabled: false,
|
||||
|
||||
@ -212,6 +212,22 @@ function EditView({
|
||||
});
|
||||
};
|
||||
|
||||
const handleChange = ({ target: { name, value, type } }) => {
|
||||
let inputValue = value;
|
||||
|
||||
// Empty string is not a valid date,
|
||||
// Set the date to null when it's empty
|
||||
if (type === 'date' && value === '') {
|
||||
inputValue = null;
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: 'ON_CHANGE',
|
||||
keys: name.split('.'),
|
||||
value: inputValue,
|
||||
});
|
||||
};
|
||||
|
||||
const handleSubmit = async e => {
|
||||
e.preventDefault();
|
||||
const schema = createYupSchema(layout, { groups: groupLayoutsData });
|
||||
@ -278,7 +294,6 @@ function EditView({
|
||||
strapi.notification.error(error);
|
||||
}
|
||||
} catch (err) {
|
||||
console.log({ formErrors: err });
|
||||
setIsSubmitting(false);
|
||||
const errors = get(err, 'inner', []).reduce((acc, curr) => {
|
||||
acc[
|
||||
@ -291,6 +306,7 @@ function EditView({
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
dispatch({
|
||||
type: 'SET_ERRORS',
|
||||
errors,
|
||||
@ -322,13 +338,7 @@ function EditView({
|
||||
keys: name.split('.'),
|
||||
});
|
||||
}}
|
||||
onChange={({ target: { name, value } }) => {
|
||||
dispatch({
|
||||
type: 'ON_CHANGE',
|
||||
keys: name.split('.'),
|
||||
value,
|
||||
});
|
||||
}}
|
||||
onChange={handleChange}
|
||||
onRemove={keys => {
|
||||
dispatch({
|
||||
type: 'REMOVE_RELATION',
|
||||
@ -448,13 +458,7 @@ function EditView({
|
||||
keys: name.split('.'),
|
||||
});
|
||||
}}
|
||||
onChange={({ target: { name, value } }) => {
|
||||
dispatch({
|
||||
type: 'ON_CHANGE',
|
||||
keys: name.split('.'),
|
||||
value,
|
||||
});
|
||||
}}
|
||||
onChange={handleChange}
|
||||
layout={get(groupLayoutsData, group.group, {})}
|
||||
pathname={pathname}
|
||||
removeField={(keys, shouldAddEmptyField) => {
|
||||
@ -481,13 +485,7 @@ function EditView({
|
||||
layout={layout}
|
||||
modifiedData={modifiedData}
|
||||
name={name}
|
||||
onChange={({ target: { name, value } }) => {
|
||||
dispatch({
|
||||
type: 'ON_CHANGE',
|
||||
keys: name.split('.'),
|
||||
value,
|
||||
});
|
||||
}}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
@ -130,7 +130,7 @@ const createYupSchemaAttribute = (type, validations) => {
|
||||
.typeError();
|
||||
}
|
||||
if (['date', 'datetime'].includes(type)) {
|
||||
schema = yup.date().typeError();
|
||||
schema = yup.date();
|
||||
}
|
||||
|
||||
Object.keys(validations).forEach(validation => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user