Skip to content

Conditional fields #1227

@jbenito3

Description

@jbenito3

It's a somewhat commonly requested feature to have certain fields (or sections?) in the registration form displayed only when certain other fields are selected (or have a particular value).

For example, you may be able to select between "speaker" and "participant" in a single-choice dropdown field, and depending on what you selected, only fields related to the selected role are shown. Another usecase could be selecting an "Apply for financial aid" checkbox when registering for a conference, which would then show additional (and possibly required) fields to provide more details.

On a more abstract level, this should be implemented in the following way:

  • Each registration form field has a new setting in its configuration dialog, where you can select one other field (e.g. using a dropdown) from the same registration form. Once you selected that field, depending on its type, you can choose which values of that field are needed to enable the current field. In case of a checkbox this would be "checked" or "not checked" (selecting both does not make much sense, but maybe it's not necessary to prohibit that), in case of a choice field any of its choices it would list any of its choices.
  • The form logic (on the React side) takes this into account and hides fields as needed
  • The form validation logic (on the React side) ignores validation errors from inactive fields, and also does not send data for such fields during submission (TBD: what to do when editing a registration and there's already data - keep it or remove it?)
  • On the backend, this needs to be enforced as well
  • Unit tests should be added, in particular on the backend, if there are edge cases or other cases where bugs / unexpected behavior are likely

# Original ticket imported from Trac below:

Would it be difficult to add a capability for conditional fields in the registration form?

For instance,

  • if we check a box or select a radio button --> show other fields
  • even more, if we select a given country --> show extra fields (VISA requirement) [Requested by Jochen Thaeder for QM2014]

As well, a field could trigger to show/hide a different section.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions