Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Streamfield with a nested StructBlock #23

Open
easherma opened this issue Feb 19, 2020 · 1 comment
Open

Support Streamfield with a nested StructBlock #23

easherma opened this issue Feb 19, 2020 · 1 comment

Comments

@easherma
Copy link

Similar to #12

I have a case like this:

StreamField(
        [
            ('section', StructBlock(
                [
                    ('section_heading_en', TextBlock(label='Heading [en]')),
                    ('pages', ListBlock(
                        PageChooserBlock(label="Page", page_type=[InformationPage, ServicePage]),
                        help_text='Select existing pages in the order you want them \
                        to display within each heading.\
                        Pages should be added only once to any single guide.')
                     ),
                ],
                label="Section"
            )),
        ],
        verbose_name='Add a section header and pages to each section',
        blank=True
    )

This is sorta puesdo code/bad formatting, but ideally I ought to be able to do something like:

    'section': wagtail_factories.StructBlockFactory({
        'section_heading_en': description = factory.Faker('text')
        'pages': ListBlockFactory({
            PageChooserBlockFactory
            })
        })
        }
    )
@jams2
Copy link
Contributor

jams2 commented Jul 25, 2022

Hi @easherma , to clarify: is your request to allow defining "anonymous" StructBlockFactories inline on a StreamFieldFactory declaration - i.e. not by subclassing StructBlockFactory separately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants