octobercms / october

Self-hosted CMS platform based on the Laravel PHP Framework.
https://octobercms.com/
Other
10.99k stars 2.22k forks source link

Using drafts doesn't work as expected on blueprints using groups #5802

Open thedoofus opened 4 weeks ago

thedoofus commented 4 weeks ago

I have a Page blueprint, that uses groups to allow me to choose between a Simple page and a Builder page. The Builder blueprint also uses several mixins to allow me to add different section types to a page.

I can create a builder page, then start a new draft from it. But when I attempt to apply the new draft, the page reverts back to the original primary record and it appears all my changes on the draft are lost.

The drafts feature works perfectly fine from a simple page . But things just get a bit funky with the builder page type.

I'm also not aple to switch between simple and builder page when making a draft this way, the button isn't available to me in the top right corner.

Here's my set blueprint set up if it helps.

page.yaml

handle: Content\Pages;
type: structure
name: Pages
drafts: true
primaryNavigation:
  label: Pages
  icon: ph ph-browsers
  order: 150
groups:
  dynamic:
    name: Dynamic Page
    fields:
      builder:
        tab: Edit
        type: mixin
        name: Builder
        source: Page\Builder
  simple:
    name: Simple Page
    fields:
      content:
        label: Content
        tab: Edit
        type: richeditor
        span: adaptive
        column: false
        scope: false

builder.yaml

handle: Page\Builder
type: mixin
name: Builder
fields:
  builder:
    type: repeater
    label: Builder
    displayMode: builder
    span: adaptive
    prompt: Add a Block
    groups:
      cards:
        name: Cards
        icon: icon-columns
        description: A grid of cards
        useTabs: true
        fields:
          cards:
            type: mixin
            source: Builder\Cards
      grid:
        name: Grid
        icon: icon-th-large
        description: A grid of tiles
        useTabs: true
        fields:
          grid:
            type: mixin
            source: Builder\Grid

grid.yaml

handle: Builder\Grid
type: mixin
name: Grid
fields:
  content:
    label: Content
    tab: Edit
    type: richeditor
    span: full
  items:
    tab: Edit
    type: mixin
    source: Builder\GridItem

griditem.yaml

handle: Builder\GridItem
type: mixin
name: Grid Items
fields:
  items:
    label: Grid Items
    type: repeater
    displayMode: builder
    prompt: Add Grid Item
    form:
      fields:
        content:
          tab: General
          label: Content
          type: richeditor
          span: full
        icon:
          tab: General
          label: Icon
          type: mediafinder
          mode: image
          span: left
          maxItems: 1
        icon_alt_text:
          tab: General
          label: Alt Text
          type: text
          span: right
        card_link_text:
          label: Card Link Text
          default: Find out more
          span: left
          type: text
        card_link_target:
          label: Card Link Page
          type: pagefinder
          span: right

cards.yaml

handle: Builder\Cards
type: mixin
name: Cards
fields:
  content:
    label: Content
    tab: Edit
    type: richeditor
    span: full
  items:
    tab: Edit
    type: mixin
    source: Builder\Card

card.yaml

handle: Builder\Card
type: mixin
name: Card
fields:
  items:
    label: Cards
    type: repeater
    displayMode: builder
    prompt: Add Card
    form:
      fields:
        content:
          tab: General
          label: Content
          type: richeditor
          span: full
        icon:
          tab: General
          label: Icon
          type: mediafinder
          mode: image
          span: left
          maxItems: 1
        icon_alt_text:
          tab: General
          label: Alt Text
          type: text
          span: right