4

We are implementing Camunda on our application and we have a problem with forms

We need to implement our own form field type. We use the Camunda Modeler and use the custom type in the Type attribute of the field but when we try to deploy the war we always see the same error

ENGINE-16004 Exception while closing command context: ENGINE-09005 Could not parse BPMN process. Errors:
* unknown type 'file' [...]

We searched in the documentation but we don't see how to implement custom form field types

Any idea how to solve this?

Thanks in advance

1
  • I suggest adding an issue in the camunda jira, clearly describing the use-case
    – ThomasRS
    Commented Jul 5, 2016 at 19:53

2 Answers 2

1

You didn't provide much information on your project and how you try to use custom types in embedded? TaskForms. Camunda has a nice example how to do this with embedded TaskForms here: https://github.com/camunda/camunda-bpm-examples/tree/master/usertask/task-form-embedded-serialized-java-object

1
  • OP asks about a generated form, not an embedded form. The example is helpful, though, it shows how a customer object containing a list of addresses can be edited and rendered.
    – dschulten
    Commented Dec 1, 2018 at 6:46
1

The custom type in generated forms is for types which can be rendered as the value of a single html input field, it is not useful to render complex structures like tables or multiple inputs for bean properties.

https://forum.camunda.org/t/camunda-custom-form-field-type/501 describes how the custom type works:

The custom type must extend AbstractFormFieldType, which provides mappings between model types and form display types, see DateTypeValue for an example. Then you must tell the bpmn engine about your custom type using ProcessEngineConfiguration.setCustomFormTypes() in a ProcessEnginePlugin which has access to the bpm engine configuration.

The generated form will render the form display type as a single input field, only alternatives are datepicker for date and select for enum, as you see in HtmlFormEngine#renderFormField:

if(isEnum(formField)) {
  // <select ...>
  renderSelectBox(formField, documentBuilder);

} else if (isDate(formField)){

  renderDatePicker(formField, documentBuilder);

} else {
  // <input ...>
  renderInputField(formField, documentBuilder);

}

This is org.camunda.bpm.engine.impl.form.engine.HtmlFormEngine#renderInputField, it renders a single input:

protected void renderInputField(FormField formField, 
      HtmlDocumentBuilder documentBuilder) {

  HtmlElementWriter inputField = new HtmlElementWriter(INPUT_ELEMENT, true);
  addCommonFormFieldAttributes(formField, inputField);

  String inputType = !isBoolean(formField) ? TEXT_INPUT_TYPE : CHECKBOX_INPUT_TYPE;

  inputField.attribute(TYPE_ATTRIBUTE, inputType);

  // add default value
  Object defaultValue = formField.getDefaultValue();
  if(defaultValue != null) {
    inputField.attribute(VALUE_ATTRIBUTE, defaultValue.toString());
  }

  // <input ... />
  documentBuilder.startElement(inputField).endElement();
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.