Hello,
I just want to save an approach how to extend CheckboxSelectMultiple class for using ArrayField as a set of possible choices.
from django.forms import CheckboxSelectMultiple
class CheckboxSelectMultipleList(CheckboxSelectMultiple):
def format_value(self, value):
if isinstance(value, str):
return value.split(',')
class TagChoices(TextChoices):
tag1 = 'tag1'
tag2 = 'tag2'
class MyPage(Page):
...
tags = ArrayField(CharField(max_length=255, blank=True), default=list)
content_panels = Page.content_panels + [
...
FieldPanel('tags', widget=CheckboxSelectMultipleList(choices=TagChoices.choices)),
]
