formio / formio.js

JavaScript powered Forms with JSON Form Builder
https://formio.github.io/formio.js
MIT License
1.89k stars 1.06k forks source link

[BUG] Checking and unchecking the multiple option does not reset the defaultValue of a component #4752

Closed SilviaAmAm closed 9 months ago

SilviaAmAm commented 2 years ago

Environment

Please provide as many details as you can:

Steps to Reproduce

  1. Open the Formio builder https://formio.github.io/formio.js/app/builder
  2. Drag a textfield component into the form and save it
  3. Drag another textfield component into the form.
  4. Click on the data tab.
  5. Check 'Multiple Values'.
  6. Save the component.
  7. Click on the cog icon (edit) of the second text field.
  8. Click on the data tab.
  9. Uncheck 'Multiple Values'.
  10. Save the component.
  11. Scroll to where the form is rendered. In the first textfield enter the value 'test'
  12. Scroll to where the data is shown. Note that the second textfield is populated with an empty array.

Note: This happens also for other component types, not only textfield.

Expected behavior

The second textfield should have as defaultValue an empty string, since the multiple attribute is false.

Observed behavior

The second textfield has as defaultValue an empty array, even though the multiple attribute is false.

Example

Screen recording of the steps above: https://watch.screencastify.com/v/CedcUwKKm9mB1VNS6aRJ

daneformio commented 9 months ago

Closing this thread as it is outdated. Please re-open if it is still relevant. Thank you for your contribution!