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.

Support

Conditional form -- show admin form on all pages except XYZ

admin form

Started by Trevor Robertson 7 years ago · 2 replies · 573 views
7 years ago

What I am trying to figure out is whether there is a good way to enable a blueprint / backend form on various pages based on a condition. This is similar to how ACF in WordPress has the line "Show this field group if ... "

I know I can make a form for just a specific page by matching the .yaml file to a template .twig file of the same name. However, I'm looking for more fine grain control, and I don't want to have make the same form 10 times for 10 different pages just to prevent it showing up on say my home page. So what I'm hoping is possible is these two things:

1) Display a form in the admin of just a list of specific pages

  • Right now I'm creating fields in blueprints/default.yaml as I want these fields on most pages, but they should NOT be showing up on certain pages which they do right now since dafault.yaml seems to apply to all pages, even if you're using a different template.

2) Display the form if the parent page is XYX

  • This would be a bonus if it were possible, but definitely would be helpful.

Any tips or help on this would be appreciated...

last edited 07/17/19 by Trevor Robertson
7 years ago

I hadn't noticed that part of the docs, thanks!! That's very cool functionality, I can make use of that for sure, but it doesn't help in this case.

I guess one way around it is to instead create a new page template that is my de-facto default, like something called standard.html.twig and then basically assign every page except the one or two pages that I don't want the default form on to that new template. But that seems pretty dang hacky. I really hope there is a better way?

I have think lots of folks have encountered this. My example is some hero/header fields (image and heading text). Every page on the site has the same hero layout, except the home page, which has a unique header so it doesn't need those default fields. And so we should be able to not show those fields on the home page.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 53 9 hours ago
Support · by Anna, 3 days ago
2 59 12 hours ago
Support · by Justin Young, 13 hours ago
1 30 13 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 56 5 days ago