getgrav / getgrav/grav-plugin-admin

Conditional field - Set condition to other/sibling fields

Open
#1,501 5 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

In the blueprint file for a template i would like to use a repeater/list field,
that has a select field with options,
and conditional fields that evaluate the users selected choice to displays fields accordingly.

I would like to use this for long articles, where the user could add/switch different types of components

How do i set a condition to the value of the select field (in repetition)?
As the code is now, only the select is visible and the conditionals have no effect.

```
header.field.selection:
type: list
style: vertical
label: Repeater/list with conditional field selection
fields:
.select: # this select sets the boolean for the conditional fields
type: select
size: long
classes: fancy
label: Select the type of field you would like to add
options:
tinymce: Textarea
slideshow: Slideshow
testimonial: Testimonial
video: Video
.tinymce:
type: conditional # if Textarea was selected render the tinymce fields
condition: "header.field.selection.select is same as('tinymce') ? 'true' : 'false'"
fields:
.fieldName:
type: text
label: Tinymce
.slideshow:
type: conditional # if slideshow was selected render the slideshow fields
condition: "header.field.selection.select is same as('slideshow') ? 'true' : 'false'"
fields:
.fieldName2:
type: text
label: Slideshow
.testimonial:
type: conditional # if testimonial was selected render the testimonial fields
condition: "header.field.selection.select is same as('testimonial') ? 'true' : 'false'"
fields:
.fieldName3:
type: text
label: Testimonial
.video:
type: conditional # if video was selected render the video fields
condition: "header.field.selection.select is same as('video') ? 'true' : 'false'"
fields:
.fieldName4:
type: text
label: Video
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.