Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

FieldBlock created for MultiValueField instance throws javascript error. #43

Open
jonathanpglick opened this issue Jul 26, 2019 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@jonathanpglick
Copy link

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 BertrandBordage added the bug Something isn't working label Jul 31, 2019
@BertrandBordage
Copy link
Contributor

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

@BertrandBordage
Copy link
Contributor

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
Copy link
Author

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.

@BertrandBordage BertrandBordage added the enhancement New feature or request label Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants