umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
30 stars 0 forks source link

DateTime Field in Backend not clearing #987

Open soeren-eckel-adesso opened 1 year ago

soeren-eckel-adesso commented 1 year ago

A brief description of the issue goes here.

Date time in backend not clearing

image

Reproduction

Version: 10.2.3

If you're filing a bug, please describe how to reproduce it. Include as much relevant information as possible, such as:

Bug summary

If a date time in backend is set and users tries to clear it nothing is updated and the old value is still present.

Steps to reproduce

Expected result

date time is not set anymore

Actual result

former date is still set

soeren-eckel-adesso commented 1 year ago

A javascritp error is thrown:

image

See also https://github.com/umbraco/Umbraco.Forms.Issues/issues/996 for a workaround, so javascript error is not throw anymore, but backend throws a parsing error. However this can also be soved as a workaround in Editors.Form.FormController Angular controller.

   function parseEditedValues(selectedEntryDetail) {
                // If multiple values have potentially been saved, the editor supporting multi-value save operations (e.g. dropdown-multiple.html)
                // will have saved a flag on the model object.
                // If set, we need to parse out the comma separated values.
                // If not set, we have a single value.
                if (selectedEntryDetail.multipleValuesSaved) {
                    return selectedEntryDetail.value.split(", ");
                }

                if(selectedEntryDetail.viewName === 'date' && !selectedEntryDetail.value){
                    return [];
                }

                return [selectedEntryDetail.value];
            }