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

Subclassing BaseBlock gives me an "Advanced setting" in the editor, but the custom_css_class is not available in the template #573

Open
weholt opened this issue May 9, 2023 · 1 comment
Labels
Type: Question Further information is requested

Comments

@weholt
Copy link

weholt commented May 9, 2023

I love the "Advanced settings" fields in the blocks in crx, but when I try to subclass BaseBlock in my own blocks I see the advanced settings fields in the editor, they're saved correctly, but does not appear anywhere on my object instance and is not available in my templates. What am I doing wrong?

from coderedcms.blocks import BaseBlock
from wagtail.core.blocks import BooleanBlock
from wagtail.snippets.blocks import SnippetChooserBlock


class FamousQuoteBlock(BaseBlock):
    """This will insert a famous quote block"""

    quote = SnippetChooserBlock("quotes.Quote", required=False)
    random_quote = BooleanBlock(required=False)

    class Meta:
        icon = "user"
        form_classname = "quote-block struct-block"
        template = "quotes/blocks/quote_block.html"
@weholt weholt added the Type: Question Further information is requested label May 9, 2023
@vsalvino
Copy link
Contributor

Within the block, it should be available as self.settings. You can see an example template here that is using self.settings.custom_css_class: https://github.com/coderedcorp/coderedcms/blob/dev/coderedcms/templates/coderedcms/blocks/image_block.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants