From 899b9e5b716697c03314cb516dfb9a6dd49015f4 Mon Sep 17 00:00:00 2001 From: ktz03 <2484593937@qq.com> Date: Sun, 16 Aug 2026 14:23:06 +0800 Subject: [PATCH] feat(InputDate): add emptyValue for cleared date submissions --- packages/amis/src/renderers/Form/InputDate.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/amis/src/renderers/Form/InputDate.tsx b/packages/amis/src/renderers/Form/InputDate.tsx index dd4e58a545a..73108e8c0e7 100644 --- a/packages/amis/src/renderers/Form/InputDate.tsx +++ b/packages/amis/src/renderers/Form/InputDate.tsx @@ -26,6 +26,11 @@ export interface AMISInputDateSchemaBase extends AMISFormItem { */ clearable?: boolean; + /** + * 清空后写入表单的值,默认空字符串 + */ + emptyValue?: any; + /** * 存储格式 */ @@ -408,7 +413,8 @@ export default class DateControl extends React.PureComponent< step: 1 } }, - clearable: true + clearable: true, + emptyValue: '' }; dateRef?: any; @@ -609,7 +615,10 @@ export default class DateControl extends React.PureComponent< // 值的变化 @autobind async handleChange(nextValue: any) { - const {dispatchEvent} = this.props; + const {dispatchEvent, emptyValue} = this.props; + if (nextValue === '' || nextValue == null) { + nextValue = emptyValue; + } const dispatcher = dispatchEvent( 'change', resolveEventData(this.props, {value: nextValue})