Skip to content

Latest commit

 

History

History
50 lines (36 loc) · 1.16 KB

details.md

File metadata and controls

50 lines (36 loc) · 1.16 KB

Details

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

from wagtailnhsukfrontend.blocks import DetailsBlock,

class MyPage(Page):
  body = StreamField([
      ...
      ('details', DetailsBlock()),
      ...
  ])

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

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

class CustomDetailsBody(DetailsBlock.BodyStreamBlock):

  # Add a custom block
  extra = MyExtraBlock()


class CustomDetailsBlock(DetailsBlock):

  body = CustomDetailsBody(required=True)


class MyPage(Page):
  body = StreamField([
      ...
      ('details', CustomDetailsBlock()),
      ...
  ])

Reference