it is destroying streamforms app
hazho opened this issue · 1 comments
whenever I include "wagtail-react-streamfield" into "installed app", it making the streamfield unavailable, if the streamfields' blocks customized, otherwise no issues happens..!
check that please
I tried to use it and faced indeed a JS crash when trying to add a WagtailFormBlock
.
It’s because wagtailstreamforms uses a hack to display some text in the StructBlock: it uses InfoBlock
, a subclass of CharBlock
that doesn’t render an HTML input. This is not in line with what React StreamField expects, because all CharBlocks
must render an HTML input.
I tried modifying WagtailFormBlock
so that it uses a StaticBlock
instead, and it worked:
form_reference = blocks.StaticBlock(
admin_text=_("This form will be given a unique reference once saved"),
)
So wagtailstreamforms has to do something like that to support wagtail-react-streamfield. The good thing is that it’s backwards compatible with the existing StreamField.
Note that this will show a Form reference
label above the block. To work around that, wagtailstreamforms can rewrite its InfoBlock
this way:
class InfoBlock(blocks.StaticBlock):
@property
def definition(self):
definition = super().definition
definition['label'] = None
return definition
form_reference = blocks.StaticBlock(
admin_text=_("This form will be given a unique reference once saved"),
)