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

Not possible to set custom classes on input fields with the tailwind renderer #118

Open
boosh opened this issue Mar 12, 2024 · 1 comment

Comments

@boosh
Copy link

boosh commented Mar 12, 2024

Hey, I found an issue trying to set custom classes on widgets.

The renderer overwrites classes declared on a widget, making it impossible to do this:

    my_button = forms.CharField(
        label="",
        widget=forms.widgets.TextInput(
            attrs={
                "type": "button",
                "value": "Configure",
                'class': 'btn-configure',     # never included in the class attribute
            }
        ),
    )

Fields should add to any existing attributes instead of replacing them.

@jrief
Copy link
Owner

jrief commented Mar 31, 2024

You must override the class FormRenderer. Simply inherit from formset.renderers.tailwind.FormRenderer and override the method to add the CSS class, aka. _amend_text_input().

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

No branches or pull requests

2 participants