Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

Relation popup: move secondary tabs to a tab

3
by AIC BV, last modified on March 15th, 2022

When you display a relation list and click on it, it opens a popup (if not using recordUrl). The SecondaryTab fields in your fields.yaml are placed under a label called 'Misc'. This is the value of 'defaultTab' for SecondaryTabs.

See:

The annoying part (in my opinion) is that these fields are not displayed in a tab. These fields will always be displayed at the bottom of your relation popup.

If you want, you can modify your fields.yaml, allowing you to place these fields in a tab. It's actually really easy.

1) Create a custom context for your relation popup using 'context: myValue'

myRelation:
    label: myRelation
    view:
        ...
    manage:
        form: ~/plugins/author/plugin/models/model/fields.yaml
        context: relation

2) Now you can use '@relation' in your fields.yaml. Whenever you manage myRelation, it will now have the context 'relation', allowing you to display the fields that you desire. For example:

created_at@relation:
            tab: Misc
            label: Created at
            type: datepicker
            mode: date
            format: d/m/Y
            default: now

This field will only be shown when you are managing myRelation with the context: relation.

3) In SecondaryTabs, you can add @create, @update, @preview, to display the field when NOT in context: relation

secondaryTabs:
    fields:
        created_at:
            label: Created at
            type: datepicker
            mode: date
            format: d/m/Y
            default: now
            context: ['create', 'update', 'preview']

created_at will now be displayed in the secondaryTabs fields when in context: Create, Update, Preview. created_at will now be displayed in the relation popup fields when in context: relatiation. The only downside is that you have defined created_at twice in your fields.yaml file.

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?