Some fields in my blueprint do not make sense when a specific page option is set. I thought about disabling these fields when a condition is met. The condition (in a page method) has the correct string value (true or false) as can I see in the debugging label output.
But how does it work in conjunction with the disabled setting of a field? Currently, the teaser field is always disabled and independent from the redirect value of a page.
type: group
fields:
teaser:
type: select
label: "Mit welchem Element soll die Seite eingeleitet werden? {{ page.isRedirectEnabled }}"
default: none
translate: false
disabled: "{{ page.isRedirectEnabled }}"
options:
none: Mit keinem Element
image: Mit einem Einzelbild
gallery: Mit einer Bildergalerie
type: group
fields:
teaser:
type: select
label: "Mit welchem Element soll die Seite eingeleitet werden? {{ page.isRedirectEnabled }}"
default: none
translate: false
when:
redirect: false # only show this field when redirect is false
options:
none: Mit keinem Element
image: Mit einem Einzelbild
gallery: Mit einer Bildergalerie
For me, this only works in parent blueprints (like pages/default.yml), not in section snippets (like sections/page-content.yml). I try to build universal blueprint snippets which decide for themselves what to show.
Your solution would work (but then I always need to adapt the parent blueprint to the extended snippet):
No, queries are still not possible for the disabled property. Also creating blueprints based on PHP won’t help if you need to access values on the same page. It would work based on a fixed page that you can fetch by its ID or the site object.