Skip to content

How to use the conditional field #248

Answered by simonswiss
NoelOConnell asked this question in Q&A
Discussion options

You must be logged in to vote

Hey! First of all, sorry for the very late response.

The way the conditional field works is as follows. It lets you setup a discriminant for a condition that can be either a checkbox or a select field with a few options.

You can then display an entirely different set of fields based on the condition, by providing a key for each condition (true/false if you used a checkbox, and each possible value if you used a select.

Checkbox condition

Let's say you want to optionally display SEO title/description fields, but only if a user checks a checkbox.

Let's setup the following field in our schema:

seo: fields.conditional(
  // First, we define a checkbox to drive the yes/no condition
  fields.che…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@NoelOConnell
Comment options

@simonswiss
Comment options

Answer selected by simonswiss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants