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

Grav not saving custom fields from a blueprint

first-time

Solved by Alan Coggins View solution

Started by Chris 4 years ago · 3 replies · 610 views
4 years ago

Hi ya,

Since im new to GRAV, i'm likely to be the error here.

I created a few supplemental fields to extend the default page view in my theme, but when i save the post only the page title is getting saved.

This is the code I wrote for the blueprint.

YAML
title: Homepage test
'@extends':
    type: default
    context: blueprints://pages

form:
  fields:
    tabs:
      type: tabs
      active: 1

      fields:
        content:
          fields:
            content.headingone:
              type: text
              style: vertical
              label: Heading line one

            content.headingtwo:
              type: text
              style: vertical
              label: Heading line two

            linkbox:
              type: section
              title: Links
              underline: true

            linkbox.links:
              name: links
              type: list
              style: vertical
              label: Links
              fields:
                .text:
                  type: text
                  label: title
                .desc:
                  type: text
                  label: description
                .url:
                  type: text
                  label: URL

            textboxes:
              type: section
              title: Text boxes
              underline: true

            textboxes.items:
              name: textboxes
              type: list
              style: vertical
              label: Text boxes
              fields:
                .itemheading:
                  type: text
                  label: Heading
                .itemimage:
                  type: filepicker
                  folder: 'theme://images/icons'
                  label: Image
                  preview_images: true
                  accept:
                    - .png
                    - .jpg
                    - .svg
                .itemtext:
                  type: markdown
                  label: Blurb

            socials:
              type: section
              title: Socials
              underline: true

            socials.sociallinks:
              name: sociallinks
              type: list
              style: vertical
              label: Social links
              fields:
                .text:
                  type: text
                  label: title
                .url:
                  type: text
                  label: URL

Any ideas? I think i may have missed something obvious, but not sure how best to trace errors.

I'm running Grav 1.7.13 on a MAMP instance.

last edited 12/28/21 by Chris
4 years ago Solution

Not really sure about all this either (I'm new to Grav too) but I think the field names need to start with header.

So this is what I used for my custom fields...

YAML
          fields:
             header.shortDescription:
              type: text
              label: 'Short Description'
             header.price:
              type: number
              label: 'Price'
last edited 12/28/21 by Alan Coggins
4 years ago

@suthen, To complement to @ozfiddler's correct answer:

According to the doc How to name fields:

It's important that fields use the header.* structure, so field content is saved to the Page Header when saved.

last edited 12/29/21 by pamtbaau
4 years ago

All working now! thanks all!

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 134 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