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

Page Blueprint Issues | Fields/Tabs not showing up

first-time form

Started by Cedric W 8 years ago · 9 replies · 2172 views
8 years ago

Hello, I'm new to Grav. I'm trying to created a new tab to add disclosures to the page. The pages I'm creating are different events that require their own custom disclosures and not just the same info.

I've created a template for Event pages in my custom theme (event.html.twig). I created a blueprints folder within my custom theme and created an event.yaml blueprint.

Here is my Blueprint code. Am I missing something. I've cleared the cache. I've even copied code from the Antimatter theme but nothing changes.

YAML
title: Disclosures
    '@extends':
      type: default
    form:
      fields:
          tabs:
          type: tabs
              active: 1
              fields:
                  content:
                      type: tab
                      title: Disclosure
                      fields:
                          header.disclosure:
                              name: disclosure
                              type: list
                              style: vertical
                              label: Disclosures
                              fields:
                                  .title:
                                      type: text
                                      label: Title
                                  .content:
                                      type: textarea
                                      label: Disclosure
8 years ago

Hi
It may be that line 7 should be "tab" not "tabs". Also I don't know if its copy/paste into the forum but you should only have 2 spaces for your indents, this looks more like tabs which would kill it.
so like:
title: 'Price List'
'@extends':
type: default

YAML
form:
  fields:
    tabs:
      fields:
        tabs:
          type: tab
          title: 'Disclosure'
          fields:

etc
Normally just switching between "Normal" and "Expert" will be enough to refresh the page to show any changes.

8 years ago

Thanks for the quick feedback.

I reformatted my code with your suggestions @csixtyfour ...removed the tabs and just did two spaces...still no cigar though. It's just weird because even creating a blueprint via devtools doesn't result in any changes in the admin.

YAML
title: Disclosures
  '@extends':
    type: default
    form:
      fields:
        tabs:
        type: tab
        active: 1
          fields:
            content:
              type: tab
              title: Disclosure
                fields:
                  header.disclosure:
                    name: disclosure
                    type: list
                    style: vertical
                    label: Disclosures
                    fields:
                      .title:
                        type: text
                        label: Title
                      .content:
                        type: textarea
                        label: Disclosure
8 years ago

Spaces are key as mentioned. Also the title and form need to be on the same column. And there are a few indents you are missing, which is super important to get right with a blueprint file. Check this out:

YAML
form:
  fields:
    tabs:
      type: tab
      active: 1
      fields:
        disclosure:
          type: tab
          title: Disclosure
          fields:
            header.disclosure:
              name: disclosure
              type: list
              style: vertical
              label: Disclosures
              fields:
                .title:
                  type: text
                  label: Title
                .content:
                  type: textarea
                  label: Disclosure

Because '@extends' is a child of title, you want to reset your indentation for form. Also you want to make sure you keep all properties of an item on the same column and only indent for child items. Hope that makes sense. Let me know if that works for you!

8 years ago

I was about to replyu too, but looks like @apotropaic got it right, except for the line 4 that should be plural iirc.

So:

YAML
form:
  fields:
    tabs:
      type: tabs
      active: 1
      fields:
        disclosure:
          type: tab
          title: Disclosure
          fields:
            header.disclosure:
              name: disclosure
              type: list
              style: vertical
              label: Disclosures
              fields:
                .title:
                  type: text
                  label: Title
                .content:
                  type: textarea
                  label: Disclosure
8 years ago

@apotropaic:
form:
fields:
tabs:
type: tab
active: 1
fields:
disclosure:
type: tab
title: Disclosure
fields:
header.disclosure:
name: disclosure
type: list
style: vertical
label: Disclosures
fields:
.title:
type: text
label: Title
.content:
type: textarea
label: Disclosure

Omg you guys are awesome and yes I was able to get the tabs to display now. Apparently my text editor kept converting my indents to tabs instead of spaces. A quick change in my editors preferences helped. Also checked my yaml against an online validator to make sure there wasn't any simple errors like tabs. I really appreciate all of the help.

8 years ago

This may be a dumb question, but can you have more than one custom Tab? I have the Disclosure tab showing as intended but if I wanted to add say a Features tab as well, is that possible? Or do I have to work within that one custom tab?

I've tried this but it doesn't output an Accordion Tab

YAML
title: Disclosures
'@extends':
    type: default
    context: blueprints://pages
form:
  fields:
    tabs:
      type: tabs
      active: 1

      fields:
        disclosure:
          type: tab
          title: Event Disclosure

          fields:
            header.disclosure:
                type: editor
                label: Disclosure

      fields:
        accordion:
          type: tab
          title: Tab Accordion

          fields:
            header.accordion:
                type: editor
                label: Overview
8 years ago

You just had an extra fields: This shoud work:

YAML
title: Disclosures
'@extends':
    type: default
    context: blueprints://pages
form:
  fields:
    tabs:
      type: tabs
      active: 1

      fields:
        disclosure:
          type: tab
          title: Event Disclosure

          fields:
            header.disclosure:
                type: editor
                label: Disclosure

        accordion:
          type: tab
          title: Tab Accordion

          fields:
            header.accordion:
                type: editor
                label: Overview
8 years ago

Ah, thanks. I think I have a better understanding now @paul . 👍

👍 1

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1136 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 61 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 135 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 110 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 129 7 months ago