Static access of page header in conditional field

I wonder if it is possible to get (static) access to the page header in a contitional field’s condition.

I have a multi-purpose component called “Card” and want to define in the page options if the card content field is shown. I’m perfectly fine with a static option, where the page requires a reload to display the fields correctly.

Is this possible in with Grav and without JS?

My example (which is not working):

Thank you.

I suppose, if your condition returns 0 or 1, it won’t work. It should be true or false. Or you can return strings yourself. Check example in the docs

I ensured the field in the header field has a boolean value and the Conditional field itself works correct with a boolean value.

In this case the condition does not seem to get a value.

The main question is:
Is it possible to access the pages header in the page blueprint at all?

Good question actually. Docs say

Any variable accessible by twig

So page should also be available, but now I’m thinking if this might be related to the issue, where form might not have a page :thinking:

@pamtbaau, any ideas maybe?

I wonder what actually page should be in this context - if it’s a front-end form, then I’d expect page to be where form is outputted, or in module case, maybe a module page itself

1 Like

You gave me a hint.

The page object is indeed the (Flex Objects) admin page not the frontend page.

A small step forwards.

So page is actually there, but it’s an admin currently open page? :slight_smile: That’s what I was thinking, but as I saw you try to access page.header..., I assumed it must be a front-end form

I see your point. The Conditional field is listed under “Frontend Forms” in the docs.

I’m actually using it in a page blueprint in the admin since it also seems to work fine.

@stepbyweb, According the docs Available Form Fields for Use in the Admin:

In addition to the fields listed below, reserved for usage in the Admin, you can also use all the fields available in the frontend forms described in the Frontend Forms Fields Reference.


Yes, thanks. :slightly_smiling_face:

Do you probably have an answer to the main question:

Is it possible to access the page header in the page blueprint?