Skip to content

Add ability to allow Dropdown/Radio/Checkboxes to be dynamic #2684

@engram-design

Description

@engram-design

While the option-based fields like Dropdown, Radio Buttons, and Checkboxes are there to constrain users to pick from static options, there are several limitations when needing those options to be dynamic.

Right now, this is done in Twig templates by modifying the field settings with new options. These new options are stored alongside the submission, so they're retained.

I would propose a setting on these fields for options to be "Static" or "Dynamic", where when static is selected, editors must provide options as is the current case, and if the front-end user tries to submit a value not in that collection, a validation error is thrown. For dynamic, no such validation is in place. Maybe we could even provide a Twig UI for managing the logic for populating things.

What we'll also need to consider is how to handle dynamic options. While Twig is indeed very useful and powerful, we're going to run into issues with static cached sites where that Twig code isn't evaluated, leaving the options for a field empty. At least if we had the logic stored in the field settings (in the database, permanently), then that could be evaluated when rendering the form.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions