Opened 6 years ago

Last modified 6 years ago

#29468 closed Cleanup/optimization

Form Field declaration: — at Version 1

Reported by: Ivan Muller Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords: Field Widget html attrs
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Ivan Muller)

Hi guys, I want to improve the way of declear html attrs into a Fields With out declaring the default widget again.

example:
class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
full_name = forms.CharField(widget=forms.TextInput(attrs={'class': Anyclass',}))

As Field documentaiton say into the init:
"""Each Field has a default Widget that it'll use if you don't specify this. n most cases, the default widget is TextInput:"""
Woudl be god to declare it as

full_name = forms.CharField(widget_attrs={'class': Anyclass',})

Change History (1)

comment:1 by Ivan Muller, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top