open-formulieren / open-forms

Smart and dynamic forms
https://open-forms.readthedocs.io
Other
35 stars 27 forks source link

Figure out a "transform" mechanism for (AddressNL) component(s) when registering them in the Objects API #4418

Open sergei-maertens opened 3 months ago

sergei-maertens commented 3 months ago

Sparked by https://github.com/open-formulieren/open-forms/issues/3993#issuecomment-2178591720

This should assist in transitioning from the deprecated location derivation without breaking (existing) Object Type API contracts.

Currently textfields are manually wired together, so you end up with a bunch of form variables that map to certain Objects API properties, e.g.:

Replacing this with an AddressNL component would instead create:

Because the form designer doesn't have any control over the nested keys, this would require them to update the objecttypes, which creates problems in other applications.

So, I'd propose that next to the mapping of form var -> target path, you can also specify some transformation for the value, so that you can rename the nested keys during registration to make this align properly.

This should in theory also enable us to transition from deprecated -> new in an automated, backwards compatible way, or at least build some tooling to assist in this.

sergei-maertens commented 3 months ago

Note that we already do this (in a hardcoded way) to handle attachments and map components.

joeribekker commented 3 months ago

Refinement: Victorien can point in the right direction.