bpmn-io / form-js

View and visually edit JSON-based forms.
https://bpmn.io/toolkit/form-js/
Other
405 stars 102 forks source link

Unknown Values Submitted #266

Closed philippfromme closed 2 years ago

philippfromme commented 2 years ago

Describe the Bug

When using form fields with defined values importing values that don't match any of the defined values will lead to those values being submitted unless the form fields are edited.

brave_tvx66TsKyB

While this could be considered an edge case, we might want to decide what to do in that situation as the current behavior is more or less accidental.

Steps to Reproduce

  1. Use a checklist, radio, or select
  2. Import values that do not match any of the defined values
  3. Submit the form without editing the form field
  4. The unknown values are submitted even though they weren't visible in the form

Expected Behavior

Not sure what the expected behavior would be. One option is never to submit any unknown values.

Environment

nikku commented 2 years ago

Never submit any unknown values.

You define the data model by creating the form and we guarantee that nothing or what has been defined is submitted.

nikku commented 2 years ago

I had a quick look but won't be able to follow up on this at the moment. It does actually not feel like a bug to me, but like a missing feature. Moving to backlog.

Skaiir commented 2 years ago

Seconding the 'missing feature' part of this.

I would like to make the case that securing the data is a responsibility of the control, and not something at a higher scope than that. As it stands right now, all our single and multi-select controls are expected to provide something which is part of the options list, however there are controls which give you a suggested list of answers, but don't necessarily require you to stick to them. So I don't think enforcing data across everything which uses options would be the approach here.

One potential solution would be to create an options enforcer hook which optionally takes in a bool evaluation. That hook would react to option changes and, if the boolean evaluates to true, would enforce that the value(s) matches.


Given a list of options [A, B, C]

For singleselect: A => A D => null

For multiselects: [A, B, D] => [A, B]


I think this needs to be implemented by the time we release the new form-js features.