Details
-
Bug Report
-
Resolution: Fixed
-
L3 - Default
-
None
Description
Environment (Required on creation):
If you have a non-required form field on one task, then show that as a read-only field on a later task, and no value was set on the first task, then submission of the form for the second task will fail with Invalid value submitted for form field '<field>': validation of readonly failed.
As the field is readonly, it shouldn't matter if it has a value or not.
We are using readonly fields to show information from earlier steps in the process to the user. When a field is optional / not required, we expect the later form to still be submittable. However, while the form renders fine (eg empty readonly box), the form cannot be submitted even though all required values for the form have been set.
I believe that the readonly validation shouldn't require a value at submit time.
Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):
Example two-task simple process attached. When submitting, error shown in tasklist is
Steps to reproduce (Required on creation):
Create a two task process. Have a non-required field on the first task. Have that as a readonly field on the second. Try to submit the form
Observed Behavior (Required on creation):
Form submission fails with "validation of readonly failed", eg
Cannot submit task form 658d10ad-faaa-11eb-b06d-00e04c360a44: Invalid value submitted for form field 'TargetDate': validation of readonly failed.
Expected behavior (Required on creation):
Read only fields which are empty shouldn't affect submitting the form
Root Cause (Required on prioritization):
Given
A BPMN model with two succeeding user tasks:
- User Task A: has a date typed generated form field with id "foo"
- User Task B: has a readonly date typed generated form field with id "foo"
When
- In User Task A the form field "foo" is left empty, and the form is submitted
- An empty string is set as a variable to the backend
- In the backend, an empty date form field is stored as null value [1]
- In User Task B the form field "foo" with the value null is retrieved from the server
- null cannot be displayed by an HTML input field, so it is rendered with an empty string
- This difference is spotted by the form field dirty check as "changed" value: null !=== "" [2]
- The updated empty variable value is sent to the server, which results in the exception since the form field is marked as readonly, so it must not be updated
- null cannot be displayed by an HTML input field, so it is rendered with an empty string
Solution Ideas (Optional):
- In the backend, for generated form fields, store an empty string as an empty date string and don't convert it to a null value; like this, it can be retrieved as an empty string again
- Pro: easy-pick
- Con: -
- In the frontend, make dirty check for date null !=== "" => false
- Pro: easy-pick
- Con: unset variables of generated form fields are null which would not lead to setting the variables on completing a form with empty values
Hints (Optional):
[1] https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/form/type/DateFormType.java#L67
[2] https://github.com/camunda/camunda-bpm-platform/blob/master/webapps/camunda-bpm-sdk-js/lib/forms/variable-manager.js#L122-L123