From 85f7a09a1888e4a0821ee3e3820c6f8178864ff9 Mon Sep 17 00:00:00 2001 From: Niels Verbeek Date: Fri, 21 Feb 2025 10:56:28 +0100 Subject: [PATCH] feat(copy): adds documentation for datasource on_copy --- forms/data-sources.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/forms/data-sources.md b/forms/data-sources.md index 8b56275..7da991f 100644 --- a/forms/data-sources.md +++ b/forms/data-sources.md @@ -37,6 +37,14 @@ For the label, it's possible to use a dict with translated values. Note: If the labels returned from`get_data()` depend on the current user's language, you need to return a `dict` with the language code as keys instead of translating the value yourself. Returning already translated values is not supported, as it would break caching and validation. +### `on_copy`-method + +When a an answer of type TYPE_DYNAMIC_CHOICE or TYPE_DYNAMIC_MULTIPLE_CHOICE gets copied the meaning of the slug and label of the dynamic option could potentially be changed when the datasource it's data changes. During the answer copy process the linked datasource it's on_copy method will be called to decide the desired result. + +- return the same slug,label tuple to not perform any change (default behavior) +- return an altered slug or(/and) label to change the answer value +- return a None value for the slug, to discard the answer value + #### Arguments * `user`: The OIDC user object for the request