from wagtail.core.models import Page
from wagtail.core.fields import StreamField
from wagtailnhsukfrontend.blocks import CareCardBlock
class MyPage(Page):
body = StreamField([
...
('care_card', CareCardBlock()),
...
])
By default, the care card block can contain the following sub-blocks:
- RichTextBlock
- ActionLinkBlock
- DetailsBlock
- InsetTextBlock
- ImageBlock
- WarningCalloutBlock
- SummaryListBlock
To add extra sub-blocks, you must extend the CareCardBlock
class.
class CustomCareCardBody(CareCardBlock.BodyStreamBlock):
# Add a custom block
extra = MyExtraBlock()
class CustomCareCardBlock(CareCardBlock):
body = CustomCareCardBody(required=True)
class MyPage(Page):
body = StreamField([
...
('care_card', CustomCareCardBlock()),
...
])
The default heading level for care cards is 3 but this can be overwritten using a Django setting. See testapp/testapp/settings/base.py as an example. If no setting is supplied the default will remain 3.