Opened 18 years ago

Closed 18 years ago

#3066 closed defect (invalid)

NewForms RadioSelect choices problem

Reported by: Derek Hoy <django@…> Owned by: Adrian Holovaty
Component: Core (Other) Version: dev
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using a RadioSelect widget in NewForms needs choices to be put in Field and the widget definitions
(in SVN r4105)

Examples:

radio_choice = ChoiceField(
    widget=RadioSelect(choices=(('1', '1'), ('2', '2'),('3', '3'), ('4', '4'))))

radio_choice = ChoiceField(
    choices=(('1', '1'), ('2', '2')), 
    widget=RadioSelect(choices=(('3', '3'), ('4', '4'))))

radio_choice = ChoiceField(
    choices=(('1', '1'), ('2', '2'),('3', '3'), ('4', '4')), 
    widget=RadioSelect(choices=(('1', '1'), ('2', '2'),('3', '3'), ('4', '4'))))

Example 1, choices show in form, but not valid when selected.
Ex 2, choices 3,4 appear, but not valid choices.
Ex 3, all appear and are valid choices.

Change History (1)

comment:1 by Adrian Holovaty, 18 years ago

Resolution: invalid
Status: newclosed

I've given this some thought, and I'm fine with declaring this as "user error." The ChoiceField is responsible for defining a field's validation, which includes all the possible choices for the value. The RadioSelect simply defines the *presentation*. So if you make the mistake of including choices in RadioSelect that aren't defined in the ChoiceField, that is your mistake, and not the framework's mistake.

With that said, I'm open to suggestions on how we could, perhaps, make that situation easier to debug for people who don't understand what's happening.

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