mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 12:23:05 +00:00
Merge pull request #2659 from strapi/fix/#1960
Fix InputDate not working
This commit is contained in:
commit
ea3a7da846
@ -171,6 +171,7 @@ InputDateWithErrors.defaultProps = {
|
||||
style: {},
|
||||
tabIndex: '0',
|
||||
validations: {},
|
||||
value: null,
|
||||
};
|
||||
|
||||
InputDateWithErrors.propTypes = {
|
||||
@ -217,7 +218,10 @@ InputDateWithErrors.propTypes = {
|
||||
style: PropTypes.object,
|
||||
tabIndex: PropTypes.string,
|
||||
validations: PropTypes.object,
|
||||
value: PropTypes.string.isRequired,
|
||||
value: PropTypes.oneOfType([
|
||||
PropTypes.string,
|
||||
PropTypes.object,
|
||||
]),
|
||||
};
|
||||
|
||||
export default InputDateWithErrors;
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators, compose } from 'redux';
|
||||
import { createStructuredSelector } from 'reselect';
|
||||
@ -16,7 +15,6 @@ import {
|
||||
get,
|
||||
includes,
|
||||
isEmpty,
|
||||
isObject,
|
||||
toNumber,
|
||||
toString,
|
||||
replace,
|
||||
@ -260,9 +258,7 @@ export class EditPage extends React.Component {
|
||||
handleChange = e => {
|
||||
let value = e.target.value;
|
||||
// Check if date
|
||||
if (isObject(e.target.value) && e.target.value._isAMomentObject === true) {
|
||||
value = moment(e.target.value).format('YYYY-MM-DD HH:mm:ss');
|
||||
} else if (
|
||||
if (
|
||||
['float', 'integer', 'biginteger', 'decimal'].indexOf(
|
||||
get(this.getSchema(), ['fields', e.target.name, 'type']),
|
||||
) !== -1
|
||||
|
@ -88,8 +88,18 @@ export function* submit() {
|
||||
yield put(setLoader());
|
||||
const recordCleaned = Object.keys(record).reduce((acc, current) => {
|
||||
const attrType = source !== 'content-manager' ? get(schema, ['models', 'plugins', source, currentModelName, 'fields', current, 'type'], null) : get(schema, ['models', currentModelName, 'fields', current, 'type'], null);
|
||||
const cleanedData = attrType === 'json' ? record[current] : cleanData(record[current], 'value', 'id');
|
||||
let cleanedData;
|
||||
|
||||
switch (attrType) {
|
||||
case 'json':
|
||||
cleanedData = record[current];
|
||||
break;
|
||||
case 'date':
|
||||
cleanedData = record[current]._isAMomentObject === true ? record[current].format('YYYY-MM-DD HH:mm:ss') : record[current];
|
||||
break;
|
||||
default:
|
||||
cleanedData = cleanData(record[current], 'value', 'id');
|
||||
}
|
||||
|
||||
if (isString(cleanedData) || isNumber(cleanedData)) {
|
||||
acc.append(current, cleanedData);
|
||||
|
Loading…
x
Reference in New Issue
Block a user