octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.

Home Page:https://octobercms.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use "merge keys" / "block definitions" for grouped repeaters

marcogrueter opened this issue · comments

We use a lot of fields for our static pages and each field has a few fields that define options for the containers or how long a content block is visible on the page. I tried to use YAML merge keys / block definitions (honestly not sure what this is called exactly), and it seems to work well. I've made some experiments with the static page plugin as well as grouped repeaters in the FormController and everything just worked as expected. Well, it is a YAML parser / language features, but none the less...

The only thing is, that the Repeater widget displays the definitions as broken entries in the popover / dropdown menu.

Would it be possible to skip those definitions in grouped repeater yaml files? Or validate the groups so "broken" items won't show up?

Simple example to illustrate:

_define_contentFields:  &contentFields
    content:
        label: Content
        type: richeditor

content_rich:
    name: Rich Content
    fields:
        <<: *contentFields

content_rich_withTitle:
    name: Rich Content with a Title
    fields:
        title:
            label: Title
            type: text
        <<: *contentFields

This results in

image

but seems to work well otherwise (saving, rendering).

I'm not sure if the solution is something like a prefix so those fields could be skipped (Repeater::processGroupMode()), like:

if (Str::startsWith($code, '_define_')) {
    continue;
}

or some form of validation for repeater groups, so that broken groups won't get rendered.

Thank you very much for your time!

Kind regards
Marco

commented

Hey @marcogrueter

A fix for this has been included in v3.6 and documented (octobercms/docs@a0d336d)

Yay, great stuff! This will make YAML files for repeater group with general options (e. g. for timed show/hide) much neater.
Thanks!