bpmn-io / form-js

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

Ability to Restrict Available Form Elements in Form-js #1195

Open alosultan opened 6 months ago

alosultan commented 6 months ago

Feature Request: Ability to Restrict Available Form Elements in Form-js

Description

We are using the BPMN-IO Form-js editor in a Django project to allow users to create and edit forms. However, we need to restrict the available form elements to only a few basic types (e.g., text field, text area, number, date, select). Currently, the editor displays all available form elements, and we have not found a way to limit this.

Use Case

We need to provide a streamlined form creation experience where users are only allowed to add specific types of fields. This is important for maintaining consistency and simplicity in the forms created by users.

What We Tried

We attempted to use the palette configuration option to restrict the available elements, but it does not appear to work. We also tried hiding elements via CSS after the editor is initialized, but this is not an ideal solution.

Example

Ideally, we would like to configure the editor like this:

const formEditor = new FormEditor({
    container: element,
    schema: schema,
    palette: {
        'entries': {
            'form-field': {
                'group': 'tools',
                'items': [
                    { 'type': 'textfield', 'id': 'textfield', 'label': 'Text Field' },
                    { 'type': 'textarea', 'id': 'textarea', 'label': 'Text Area' },
                    { 'type': 'number', 'id': 'number', 'label': 'Number' },
                    { 'type': 'date', 'id': 'date', 'label': 'Date' },
                    { 'type': 'select', 'id': 'select', 'label': 'Select' }
                ]
            }
        }
    }
});

Request

Could you provide guidance on how to restrict the available form elements in Form-js? If this functionality is not currently supported, would it be possible to add it in a future release?

Thank you for your assistance!