Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31220 closed Bug (invalid)

Widgets ignores "cols" attribute.

Reported by: david html Owned by: nobody
Component: Forms Version: 3.0
Severity: Normal Keywords: widgets
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have tried two different packages and it appears that the cols attribute for Widget doesn't recognise the "cols" attribute

example 1

class PostAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.TextField: {'widget': AdminMarkdownxWidget (attrs={'rows': 5, 'cols': 100, 'style': ' font-size: 1.5em; font-family: HelveticaNeue;'})},
     
    }

rows and style work fine, cols doesn't change the admin form

example 2

models.TextField: {'widget': AdminPagedownWidget(attrs={'rows':20, 'cols':200,
                                                   'style': ' font-size: 1.2em;'
                                                    })},

I also note that in the documentation (https://docs.djangoproject.com/en/3.0/ref/forms/widgets/#textarea ) doesn't refer to the cols attribute so I wonder if it can still be changed

Change History (4)

comment:1 by Mariusz Felisiak, 5 years ago

Component: UncategorizedForms
Resolution: invalid
Status: newclosed
Summary: Widgets ignores cols attributeWidgets ignores "cols" attribute.

It works with builtin widgets e.g. forms.Textarea, so it's not an issue in Django but in 3rd party packages.

in reply to:  1 comment:2 by david html, 5 years ago

Replying to felixxm:

It works with builtin widgets e.g. forms.Textarea, so it's not an issue in Django but in 3rd party packages.

thanks for your fast reply.
could you please tell me how to test this e.g. without using the AdminMarkdownxWidget ? I mean replacing the admin TextField attributes. I did search in the manual but there is no example with cols. Also I am not looking to rewrite any css of the admin or using this in Django forms. Just to change it in the admin. I did try removing the widget AdminMarkdownx and it still doesn't resize.

comment:3 by Mariusz Felisiak, 5 years ago

You can just use forms.Textarea instead of AdminMarkdownxWidget.

in reply to:  3 comment:4 by david html, 5 years ago

Replying to felixxm:

You can just use forms.Textarea instead of AdminMarkdownxWidget.

Thank you, much appreciated. I can confirm that it was an issue with the external package

Note: See TracTickets for help on using tickets.
Back to Top