mirror of
https://github.com/strapi/strapi.git
synced 2025-08-31 20:33:03 +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: {},
|
style: {},
|
||||||
tabIndex: '0',
|
tabIndex: '0',
|
||||||
validations: {},
|
validations: {},
|
||||||
|
value: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
InputDateWithErrors.propTypes = {
|
InputDateWithErrors.propTypes = {
|
||||||
@ -217,7 +218,10 @@ InputDateWithErrors.propTypes = {
|
|||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
tabIndex: PropTypes.string,
|
tabIndex: PropTypes.string,
|
||||||
validations: PropTypes.object,
|
validations: PropTypes.object,
|
||||||
value: PropTypes.string.isRequired,
|
value: PropTypes.oneOfType([
|
||||||
|
PropTypes.string,
|
||||||
|
PropTypes.object,
|
||||||
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default InputDateWithErrors;
|
export default InputDateWithErrors;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators, compose } from 'redux';
|
import { bindActionCreators, compose } from 'redux';
|
||||||
import { createStructuredSelector } from 'reselect';
|
import { createStructuredSelector } from 'reselect';
|
||||||
@ -16,7 +15,6 @@ import {
|
|||||||
get,
|
get,
|
||||||
includes,
|
includes,
|
||||||
isEmpty,
|
isEmpty,
|
||||||
isObject,
|
|
||||||
toNumber,
|
toNumber,
|
||||||
toString,
|
toString,
|
||||||
replace,
|
replace,
|
||||||
@ -260,9 +258,7 @@ export class EditPage extends React.Component {
|
|||||||
handleChange = e => {
|
handleChange = e => {
|
||||||
let value = e.target.value;
|
let value = e.target.value;
|
||||||
// Check if date
|
// Check if date
|
||||||
if (isObject(e.target.value) && e.target.value._isAMomentObject === true) {
|
if (
|
||||||
value = moment(e.target.value).format('YYYY-MM-DD HH:mm:ss');
|
|
||||||
} else if (
|
|
||||||
['float', 'integer', 'biginteger', 'decimal'].indexOf(
|
['float', 'integer', 'biginteger', 'decimal'].indexOf(
|
||||||
get(this.getSchema(), ['fields', e.target.name, 'type']),
|
get(this.getSchema(), ['fields', e.target.name, 'type']),
|
||||||
) !== -1
|
) !== -1
|
||||||
|
@ -88,8 +88,18 @@ export function* submit() {
|
|||||||
yield put(setLoader());
|
yield put(setLoader());
|
||||||
const recordCleaned = Object.keys(record).reduce((acc, current) => {
|
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 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)) {
|
if (isString(cleanedData) || isNumber(cleanedData)) {
|
||||||
acc.append(current, cleanedData);
|
acc.append(current, cleanedData);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user