How to get Form Field Properties from FormFieldValidator


#1

working on:

Adding support for adding configurable property that will be the filename that will be loaded for the specific JS.

There does not seem to be a way to get the current Field that was used during the Submission.

FormFieldValidator provides the Submitted Value and validatorContext which seems to only be able to return the validator’s config value.

How can the ID of the field that is part of the submission be retrieved from FormFieldValidator?


#2

@thorben any ideas on this?


#3

Solved:

Get the Field Name/ID of the field that the validator is attached to:

    String submissionFieldName = validatorContext.getFormFieldHandler().getId();

Get the properties of the field:
validatorContext.getFormFieldHandler().getProperties()

and get a specific property:

Example: of setting a fileName from the property called “validator_file”

    String fileName = validatorContext.getFormFieldHandler().getProperties().getOrDefault("validator_file", fileNameDefault);

was based on https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/form/handler/FormFieldValidationConstraintHandler.java#L48