On Thu, 2007-11-15 at 06:47 -0800, Milan Andric wrote:
> 
> 
> On Nov 9, 12:34 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
> > On Fri, 2007-11-09 at 06:26 +0000, Milan Andric wrote:
> >
> > > On Nov 9, 12:02 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > > wrote:
> > > > > Shouldn't the form give errors and not validate?
> >
> > > > Nope. It's a bit tricky, though. The problem is that HTML forms do not
> > > > send *anything* for a checkbox that you don't check. So missing data for
> > > > a checkbox field means it wasn't checked and is, therefore, False.
> >
> > > Seems if I have (pseudocode)
> >
> > > Form:
> > >    f = someField(required=True)
> >
> > > When I pass no data into that form it should not validate?  Just
> > > doesn't seem right?
> >
> > In general, that will be true. However checkboxes are special: no data
> > just means the value wasn't checked in the form, it doesn't mean that
> > form field wasn't processed. It's an HTML oddity that Django has to
> > accomodate.
> >
> > However, now that I'm thinking about this, there might be a bug here.
> > Having required=True should mean you're required to check the box. There
> > was a huge debate about this in a ticket, but the general acceptance
> > amongst the maintainers and frequent contributors who commented was that
> > that was the correct behaviour.
> >
> > I was responsible for checking in the change that makes no data = False
> > for checkboxes (only), but I think I might have broken something in the
> > process. I'll have to look a bit deeper into this at some point.
> >
> > Malcolm
> 
> Ok, so I have a  forms.BooleanField(required=True) ... that is pretty
> much meaningless because when an html form is submitted the checkbox
> is only present in the POST if it is checked.

As I explained, boolean fields are special: required=True should be
meaning "if it isn't checked it's an error".

I also pointed out that the current behaviour is probably buggy. That
hasn't changed. I'm not going to drop everything I'm doing to fix that
right now, but I'll get to it eventually.

Malcolm

-- 
Experience is something you don't get until just after you need it. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to