Allowed values via a callback

Created on 8 August 2023, 11 months ago
Updated 11 December 2023, 7 months ago

Problem/Motivation

The Double Field module allows setting a list of allowed values to a subfield, but the list is static, meaning that it can't list values other that ones defined in the field configuration.

The real use case scenario is to list terms from a specific vocabulary in the first subfield, with an arbitrary value in the second subfield.

Currently it's not possible to populate or alter values in the first subfield option dropdown.

Proposed resolution

Introduce a schema property allowed_values_function which can contain the name of the allowed values callback and a function getAllowedValues(). The latter method returns either the result of the allowed values callback or statically defined values.

The similar approach is available in the options module where the options_allowed_values() function returns a list or values either from the allowed_values_function callback or from the configuration.

Remaining tasks

Add tests.

User interface changes

None.

API changes

None.

Data model changes

1. A property named allowed_values_function is added to the first and second subfield config schema.

✨ Feature request
Status

Closed: won't fix

Version

4.0

Component

Code

Created by

πŸ‡±πŸ‡»Latvia maijs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024