wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
https://wagtail.github.io/react-streamfield/public/
BSD 3-Clause "New" or "Revised" License
74 stars 23 forks source link

FieldBlock created for MultiValueField instance throws javascript error. #43

Open jonathanpglick opened 5 years ago

jonathanpglick commented 5 years ago

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.

image

Do you know why this is happening? Is there a way to get wagtail react streamfield to support FieldBlocks based on MultiValueField form fields?

BertrandBordage commented 5 years ago

Very good point, I’m not sure yet on how to fix that.

BertrandBordage commented 5 years ago

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?

jonathanpglick commented 5 years ago

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.