Reusing set of fields

Hi there,

I have this blueprints/fields/url.yml

label: URL PRESET
type: group
fields:
  url:
    type: url
    width: 1/3
  url_text:
    type: text
    width: 1/3
  button:
    type: toggle
    default: false
    width: 1/3
    help: When unchecked this will display as a link, otherwise it will be styled as a button

Reusing this works fine, but I’m unable to set a title for the group when i re-use this on page level. I simply see my 3 fields with zero context.

I don’t see this covered in the official documentation on reusing and extending field groups.

I could create a structure field, as this allows me for a new title, but I don’t need multiple URLs. I could also use an object, however that’s not covered on the page (or I am missing something). To use an object, there’s an extra step needed to fill in the data, which feels cumbersome.

Here’s the reference to objects for more detail.

Am I missing something? Why can’t I simply set a field blueprint and assign a custom title/label when using it?

Thank you for your expertise

Unless i have missed what you are aiming for, you could use a headline field in the group

I think you can override what the headlines says this way when you re-use the fields…

Your field group should not have the label property, see example Reusing & extending blueprints | Kirby CMS

@texnixe @texnixe

Thanks for your reply, but I do not see what I am doing wrong.

The question is rather simple.

I have a page where I need to add a few url’s, and i thought to create a field group, as the data is repeating. but for whatever reason I am unable to see the label.

When I try it a group does not display a title/label on the page.
I based myself around : Reusing & extending blueprints | Kirby CMS

This is my exact code

type: group
fields:
  url:
    type: url
    width: 1/3
  url_text:
    type: text
    width: 1/3
  button:
    type: toggle
    default: false
    width: 1/3
    help: When unchecked this will display as a link, otherwise it will be styled as a button

mypage.yml

CallToAction:
                label: Call to Action
                extends: fields/url
Appointment:
                label: Make an Appointment
                extends: fields/url

This does not show a label above my fields, but it does show the fields.
Yet only for the first CallTo Action.

I do not see the second set for Appointment.

i am really struggling hard to get this working.

I need to push several urls in my page and I was hoping to have something like

callToAction()->url()
or Appointment()->url()

Thanks for your expertise.

A field group is a set of separate fields, not a single field with an overall label. For the fields within the group, you can set individual labels.

If you want an overall label for this field group, you can use a headline field, as suggested by @jimbobrjames .

But in any case, you cannot use the field group twice (like you are doing by reusing it in CallToAction and Appointment) inside the same page blueprint, because field names need to be unique. So this approach is not valid for your use case and probably a misunderstanding about what a field group does.

This does not make sense. The fields are called individually like any other field in the page, $page->content()->get('url') ($page->url() would not work, because url() is a native Kirby method if the Page class.

If you want a single field with multiple subfields, you can use an object field: Object | Kirby CMS