Skip to content

feat(copy): adds documentation for datasource on_copy #6

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions forms/data-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down