How to add an extra content field

I would like some of my posts to contain an extra field, called subhead. Ideally, this would be presented through Admin in Add Page. I can see where the field ought to go in /system/blueprints/pages/default.yaml but I am not sure how to modify that in my own theme, which is a child theme of Antimatter.

I can see how to add a completely new tab, or add the field I want to the Blog Item tab using a blueprint.yaml file, but it would be a lot neater if I could add the field to the Content tab.

Is there an example of extending the default.yaml within a child theme? Or do I create a new default.yaml, and if so, where?

Thanks

You need to add a new page template file and define new fields for the content tab, for example:

default2.yaml

title: Default2
'@extends': default

form:
  fields:
    tabs:

      fields:
        content:
          type: tab

          fields:
            header.test:
              label: Enter something
              type: text

Thanks.

Unlike the other blueprint files, this one does not seem to have the context: element. Does that matter?

That’s the default location where to “lookup” the default file, so you can omit it.

Great. Thanks for your help and explanation.

Sorry, I’m back. I managed to get exactly what I wanted only by adding the extra field in the default.yaml. But that’s no good in the event of updates.

I copied the default.yaml into mytheme/blueprints but it didn’t seem to work there.

For neatness, I wanted the extra field to be in the existing Content tab, but I just don’t seem to be able to get that. I’ll try a completely new tab next.

I just copied the default.yaml into my new blueprint, and just grabbed what I wanted and removed the rest. Then I had full control of the content tab etc.

Interesting. I did the same and it wouldn’t work for me. Did you rename the default.yaml?

I made .yaml that matched the name of the new template I’d created. So for example if you have a blog.html.twig in your templates folder, then you create a blog.yaml file in the blueprints. I’m not sure how you would go about overriding the default.yaml/default.html.twig, I’d recommend just creating a new template entirely.

Ah, OK. I misunderstood you to say that you duplicated the actual default.yaml.

Sorry, I meant I just copied the content into a new .yaml file, and made the appropriate changes. Hope you manage to fix your issue.

I added a field for quotes in a new yaml file. The field is visible but the content is not saved.

title: Page with quote
'@extends': default

form:
  fields:
    tabs:

      fields:
        content:
          type: tab

          fields:
            quote:
              label: Quote
              type: text
              title: Quote

In the template I put

{% block quote %}
	{{ page.quote }}
{% endblock %}	

This is what the page source in admin looks like:

<div class="form-data block size-2-3" data-grav-field="text" data-grav-disabled="true" data-grav-default="null">
                                                            <div class="form-input-wrapper ">
                            <input name="quote" value="" title="Quote" type="text">
                        </div>
                                                </div>

Does this has something todo with entered text not being saved?

 data-grav-disabled="true"
---