FieldBlock created for MultiValueField instance throws javascript error.
jonathanpglick opened this issue · 3 comments
I'm creating a StructBlock
with a Django SplitDateTimeField
form field like this:
class EventBlock(blocks.StructBlock):
title = blocks.CharBlock()
text = blocks.TextBlock()
datetime = SplitDateTimeBlock()
So I implemented the SplitDateTimeBlock()
to wrap the SplitDateTimeField
like this:
class SplitDateTimeBlock(FieldBlock):
def __init__(self, *args, **kwargs):
self.field = SplitDateTimeField(*args, **kwargs)
super().__init__(*args, **kwargs)
But SplitDateTimeField
extends from MultiValueField
and it seems to be causing an error. When I click to add the EventBlock
I get a javascript error (below) and the page goes blank.
Do you know why this is happening? Is there a way to get wagtail react streamfield to support FieldBlocks based on MultiValueField form fields?
Very good point, I’m not sure yet on how to fix that.
After some further thinking, I still don’t see how react-streamfield can be adjusted to handle that without a major refactoring.
We may support that edge case in the future, but for now I suggest making an <input type="datetime" />
or something in JavaScript.
For information, did it work on the “old” StreamField?
Thanks for actually responding and thinking about this issue! My actual use case wasn't a datetime field but a 3rd party field (AnyUrlField ) that provides a multi-value field.
I got it working fine without wagtail-react-streamfield so I'll just use the "old" StreamField for now.