Opened 17 years ago

Closed 5 years ago

#5069 closed Uncategorized (wontfix)

newforms cannot initial SelectDateWidget 's value

Reported by: anonymous Owned by: nobody
Component: Uncategorized 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

form with SelectDateWidget

class Person(newforms.form):
    birthday = forms.DateField( widget=utils.widgets.SelectDateWidget())

that 's ok

form = Person(request.POST)

but cannot

form = Person(initial = request.POST)

Change History (4)

comment:1 by Adrian Holovaty, 17 years ago

What error do you get when you try this?

comment:2 by flother, 17 years ago

Resolution: wontfix
Status: newclosed

The problem is that:

form = Person(initial=request.POST)

doesn't pre-populate the rendered SelectDateWidget; it's left with defaults (1st of January of the earliest year in the list) instead, because the POST data is in a different format to that which initial is expected to be, and isn't passed to the widget. There are inherent differences between initial data and bound data; the correct way to do pass in POST data is form = Person(request.POST), as you mention.

I'm closing this as wontfix, but if there's any good reason you want to pass POST data in as the inital data, reopen the ticket.

comment:3 by kqhwejhgqwhje, 5 years ago

Easy pickings: unset
Resolution: wontfix
Severity: Normal
Status: closednew
Type: Uncategorized
UI/UX: unset

Person(request.POST) isn't the same as Person(initial=request.POST)

If our form has two fields

Code highlighting:

class Person(newforms.form):
    birthday = forms.DateField( widget=utils.widgets.SelectDateWidget())
    name = forms.CharField(max_length=80)

and we have only birthday as initial data and we want to let user fill in name we will get required field error with Person(request.POST)

Last edited 5 years ago by kqhwejhgqwhje (previous) (diff)

comment:4 by Carlton Gibson, 5 years ago

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top