Code

Opened 7 years ago

Closed 7 years ago

#3821 closed (fixed)

[patch] newforms.fields ChoiceField & MultipleChoiceField should honor widget overrides in subclasses

Reported by: Max Derkachev <mderk@…> Owned by: adrian
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

ChoiceField & MultipleChoiceField take a default widget argument in init, and it make impossible to override widget attribute on class level in subclasses. Instead of

class MyChoiceField(ChoiceField):
   widget = RadioSelect
..........
foo = MyChoiceField(choices=(....))

one must call it with widget argument every time:

foo = MyChoiceField(choices=(....), widget=RadioSelect)

Attachments (1)

fields_choices.patch (1.1 KB) - added by Max Derkachev <mderk@…> 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Max Derkachev <mderk@…>

comment:1 Changed 7 years ago by Simon G. <dev@…>

  • Component changed from Uncategorized to django.newforms
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from jacob to adrian
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 7 years ago by Gary Wilson <gary.wilson@…>

Max, in the future please create your diffs from the root of the django repository. This makes things a bit easier for anyone trying to use the patch. Thanks.

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5053]) Fixed #3821 -- Added a widget class attribute to ChoiceField and
MultipleChoiceField. This makes them consistent with other field classes and
make subclassing easier. This is a backwards compatible change. Thanks, Max
Dekachev.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.