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