Add Field Hook for Customizing Field-Level Duplication Behavior #12864
jessrynkar
started this conversation in
Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Background
Currently, when duplicating a single field (not an entire document), field values are copied as-is, with no way to easily customize or reset specific values before/after duplication. This limitation requires users to manually clean up fields, which can be tedious and lead to errors.
We support this functionality when duplicating an entire document — which allows developers to do useful things like define how unique fields should behave or reset fields. This is achieved via the
beforeDuplicate
hook, which can be applied at the collection or field level — but it only triggers during document duplication.We should support similar functionality that triggers during field-level duplication. For example, if the user has a complex
blocks
field where each block contains areadyToPublish
checkbox. When a block is duplicated, it is not ideal for that checkbox to remain checked. Developers should be able to reset the duplicated block to an unpublished state.Proposed Feature
Introduce a new field-level hook —
beforeFieldDuplicate
(or a similar) — that is called only when a field, or one of its parent fields, is duplicated.This hook would give developers full control to transform or reset field values during duplication. Example usage:
Benefits
Considerations
beforeFieldDuplicate
hook on those nested fields should also be triggered.Beta Was this translation helpful? Give feedback.
All reactions