Is my FieldRowPanel wrong?
padding = FieldRowPanel([
FieldPanel(blocks.ChoiceBlock(
required=False, choices=PADDING_CHOICES, label="Отступ сверху")),
FieldPanel(blocks.ChoiceBlock(
required=False, choices=PADDING_CHOICES, label="Отступ снизу")),
], heading="Отступы")
I am trying to do it in this place:
class ContentBlockThemed(blocks.StructBlock):
theme = blocks.ChoiceBlock(
required=True, choices=BLOCK_THEMES_CHOICES, label="Тема")
padding = FieldRowPanel([
FieldPanel(blocks.ChoiceBlock(
required=False, choices=PADDING_CHOICES, label="Отступ сверху")),
FieldPanel(blocks.ChoiceBlock(
required=False, choices=PADDING_CHOICES, label="Отступ снизу")),
], heading="Отступы")
visible = blocks.BooleanBlock(required=False, label="Видимый", default=True, help_text="По умолчанию - True")
block_content = ContentBlock()
class Meta:
icon = 'user'
form_classname = 'content-block struct-block pages-content-block'
template = 'wtblocks/content_block.html'
Nothing is displayed in the admin, although there is no error
This is not valid code.
blocks.ChoiceBlock
is only valid inside a StreamField definitionFieldRowPanel
andFieldPanel
are not valid inside a StreamField definition, only inside the 'panels' definition of a modelFieldPanel
should be passed a field name as a string, not a block objectTo control the layout of the edit form for a StructBlock (i.e. the equivalent of how you'd use FieldRowPanel in a panel definition), you need to define that layout as an HTML template and set that template as
form_template
in the block's Meta section.