Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Static access of page header in conditional field

Started by Stefan Jäger 5 years ago · 8 replies · 751 views
5 years ago

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):

card_blueprint|440x500

Thank you.

last edited 04/13/21 by Stefan Jäger
5 years ago

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

5 years ago

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?

last edited 04/13/21 by Stefan Jäger
5 years ago

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 🤔

@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
5 years ago

You gave me a hint.

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

A small step forwards.

5 years ago

So page is actually there, but it's an admin currently open page? :) 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

5 years ago

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.

last edited 04/13/21 by Stefan Jäger
5 years ago

@pamtbaau

Yes, thanks. 🙂

Do you probably have an answer to the main question:

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

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1140 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 63 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 138 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 114 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 132 7 months ago