Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establish proper custom-formio-types architecture #1054

Closed
sergei-maertens opened this issue Dec 9, 2021 · 1 comment
Closed

Establish proper custom-formio-types architecture #1054

sergei-maertens opened this issue Dec 9, 2021 · 1 comment

Comments

@sergei-maertens
Copy link
Member

Currently in the context of #297 we have a custom FormIO component type which is modified on-the-fly in the context of a submission.

This works by taking the FormIO JSON schema component and invoking any registered handlers to the type, and the component can be mutated or a new component returned that replaces the custom type (it's converted to vanilla FormIO components).

The current implementation stems from an old proof of concept worked up during a one-day hackaton, so the architecture needs to be cleared up and set in stone:

Add a new package under openforms.forms.formio_components

We are scoping this under form-design/form definitions.

Set up a custom formio type registry

Using openforms.plugins utilities, we can create a new registry class intended for FormIO types.

We should have a base plugin/type class to encapsulate formio specifics:

class CustomType(BasePlugin):
    pass

Intended python API is:

@register("myCustomType")
class MyCustomType(CustomType):
    def __call__(self, component: Dict[str, JSONValue], submission: Submission) -> Optional[JSONValue]:
        ...  # mutate component or replace it alltogether

Which means a custom formio type "myCustomType" met during configuration processing will invoke the plugin/handler with the component definition (before mutation) and the current submission for context.

Note that there is a layer approach here - the nature of such a custom type may itself again offer options in a plugin-like structure, e.g. fetching data from HaalCentraal BRP or fetching the same data from StUF-BG. This can be done in a variety of ways - project wide configuration, or possibly component-specific options. That can in turn again use a registration system.

@sergei-maertens
Copy link
Member Author

#1068 has the technical implementation details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant