Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Latest commit

 

History

History
69 lines (50 loc) · 1.57 KB

File metadata and controls

69 lines (50 loc) · 1.57 KB

Expander

from wagtail.core.models import Page
from wagtail.core.fields import StreamField

from wagtailnhsukfrontend.blocks import ExpanderBlock,

class MyPage(Page):
  body = StreamField([
      ...
      ('expander', ExpanderBlock()),
      ...
  ])

By default, the expander block can contain the following sub-blocks:

To add extra sub-blocks, you must extend the ExpanderBlock class.

class CustomExpanderBody(ExpanderBlock.BodyStreamBlock):

  # Add a custom block
  extra = MyExtraBlock()


class CustomExpanderBlock(ExpanderBlock):

  body = CustomExpanderBody(required=True)


class MyPage(Page):
  body = StreamField([
      ...
      ('expander', CustomExpanderBlock()),
      ...
  ])

Expander Group

An expander group should be used when multiple expanders are required in a list.

from wagtail.core.models import Page
from wagtail.core.fields import StreamField

from wagtailnhsukfrontend.blocks import ExpanderGroupBlock,

class MyPage(Page):
  body = StreamField([
      ...
      ('group_expander', ExpanderGroupBlock()),
      ...
  ])

Reference

Service Manual
Frontend Library