fields icon indicating copy to clipboard operation
fields copied to clipboard

[Feature] Allow multiple "Insertion in the form" (dom) blocks per entity

Open JeremieMercier opened this issue 8 months ago • 20 comments

This PR provides the ability to define multiple "Insertion in the form" blocks for the same item based on its entity

  • Created a new method findContainers() (based on findContainer()) that returns all 'dom' containers for an item based on its entity (with parent entity handling via getAncestorsOf()).
  • Adapted hooks (pre_item_add, pre_item_update, post_item_add, post_item_update) to manage multiple containers using the _plugin_fields_data_multi array.
  • Updated the populateData() function to extract input values by stripping the prefix, ensuring that data is saved into the correct columns of the injection table.
  • Modified the container.form.php file to "clean" the form data (by removing the prefix) before calling updateFieldsValues(), thereby enabling the saving of domtab containers.

Please test these modifications and verify that everything works as expected for all object types supported by the Fields plugin. Note that my tests were successful, although I focused exclusively on 'Ticket' type objects for my use case.

Checklist before requesting a review

Please delete options that are not relevant.

  • [x] I have performed a self-review of my code.
  • [ ] I have added tests (when available) that prove my fix is effective or that my feature works.
  • [ ] I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • [x] This change requires a documentation update.

Issues : #744, #789, #834

JeremieMercier avatar Apr 04 '25 11:04 JeremieMercier