Switch not working in blueprints

Hello everyone, the switch for hiding/showing dependent blocks does not work for me. Both the switch and both blocks are visible. I can’t figure out the reason. Grav v1.7.49.2 - Admin v1.10.49Below is the blueprints codeThanks.

title: 'Conditional Example'
'@extends':
    type: default
    context: blueprints://pages

form:
  fields:
    tabs:
      type: tabs
      active: 1
      fields:
        content:
          fields:
            
            # SELECTOR FIELD
            header.content_choice:
              type: select
              label: 'Content Type'
              options:
                option_a: 'Option A'
                option_b: 'Option B'
                none: 'Hide Both'
              default: none
            
            # OPTION A FIELDS
            header.option_a_field:
              type: text
              label: 'Option A Text'
              show_on: content_choice.option_a
              placeholder: 'Enter text for Option A'
            
            # OPTION B FIELDS  
            header.option_b_field:
              type: textarea
              label: 'Option B Content'
              show_on: content_choice.option_b
              placeholder: 'Enter content for Option B'


Could you share the show_on property documentation?

yes, i used show_on incorrectly, there is no such thing in the documentation. Thanks

Could you share the correct way to use it? My question isn’t a solution :slightly_smiling_face:

in blueprints yaml there is no concept show_on, I “invented” it. So your question - gave birth to the answer. I make a yaml generator and twig markup, that’s why I got the feeling that shov_on should work.

I think the closest you can get out of the box is conditional field

But I think you have to save the page to see the change in the way you want

I agree, but this is not a customer-friendly method))

show_on is a property that AI usually offers, I don’t know why it does it in Grav, but I’m sure there will be some other CMS that supports it, but it wouldn’t be bad for Grav to implement it.

Can’t this be easily achieved with conditional?

What about Elements Field, it does exactly what is needed in this case.
@mosam, example based on your markup below :backhand_index_pointing_down:

Conditional Example
title: 'Conditional Example'
extends@:
  type: default
  context: blueprints://pages

form:
  fields:
    tabs:
      type: tabs
      active: 1
      fields:
        content:
          fields:
            header.content_choice:
              type: elements
              label: 'Content Type'
              default: none
              options:
                none: 'Hide Both'
                option_a: 'Option A'
                option_b: 'Option B'

              fields:
                option_a:
                  type: element
                  fields:
                    # OPTION A FIELDS
                    header.option_a_field:
                      type: text
                      label: 'Option A Text'
                      placeholder: 'Enter text for Option A'

                option_b:
                  type: element
                  fields:
                    # OPTION B FIELDS  
                    header.option_b_field:
                      type: textarea
                      label: 'Option B Content'
                      placeholder: 'Enter content for Option B'
1 Like

I thought I saw something like that some time ago, but when I couldn’t find it quickly, I figured I was imagining it :sweat_smile:

I need to read the documentation more carefully

The conditional fields require to have one more field and the field of type elements I think I remember that it had some problems to show other fields like filepicker. I don’t know, maybe having a native property in the blueprint fields that would evaluate if another field is dependent would be interesting.

1 Like