Skip to content

[Dynamic Form] Cannot Clean Up Date Field and Save it #1937

Closed
@wuxiaojun514

Description

@wuxiaojun514

Category

[ ] Enhancement
[X] Bug
[ ] Question

Version

3.20.0

Problem Detail

I want to clean up the date field in Dynamic Form to set value to null.
By default, Dynamic Form doesn't support text input on date field, you need overwrite this field and enable allowTextInput property on DatePicker control so you can type/clean the date on it

Image

It worked at least one year ago.

Recently my team found that they cannot clean up date and it will throw error like Cannot read properties of null (reading 'toString')

Image

The root casue is on OnChange method in DynamicForm,tsx

Image

However, if I modify the code from

field.stringValue = newValue.toString();

to
field.stringValue = newValue?.toString();

I still cannot save my cleanup, because its newValue is null and Dynamic Form will only add fields whose newValue is not null/undefined into changes. So my cleanup on date fields will never be submitted.

Image

I will debug the Dynamic Form control deeply to understand the logic of this code.

Steps to Reproduce

  1. Make sure your list contains date field
  2. Override this date field in Dynamic Form to make sure the DateTimePicker enabled allowTextInput property
  3. Test your form customizer with an existing list item and try to clean up this date field
  4. You should get the same error as I got.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions