Steps to reproduce the error:
- Create a new boolean field on a content type, and mark it as required.
- Create a new node of that content type and do not set the boolean field; the form passes validation, rather than saying 'x is required'.

Comments

yoroy’s picture

Version: 7.x-dev » 8.x-dev

Confirmed on D8. The 'required' is not honored when submitting the form for a new node.

attiks’s picture

seddonym’s picture

Should this have been moved to version 8? I believe it's also a problem for version 7, maybe make a new issue for 8?

bigkevmcd’s picture

What would you expect it to do?

As a Boolean field can only be on or off, would you expect making it required to require it to be on?

If so, why bother with it at all?

Are you attempting to make a "Accepted terms?" type form? If so, then it's not the field that's required, but you require that the user submit the value as True?

attiks’s picture

@bigkevmcd if you make a checkbox required, it means it has to be checked according to the specs. So if we allow users to mark it as required it means we need to validate it as well. html5 has the same behavior, if it's required and not checked you get a validation error and you can't submit the form.

Why bother: because some countries don't allow you to subscribe people automatically to newsletters, so an 'allowed' work-around is to display a checkbox and make it required.

bigkevmcd’s picture

Which countries allow you to do this? Certainly it wouldn't be allowed under EU 2002/58/EC (or the 2003 amendment), the user is required to have explicitly opted-in to a newsletter.

attiks’s picture

It was just one example, your example in #4 where people need to explicitly check 'accept terms' is another one. Probably there might be some other use cases.

My other point remains: if we allow users to mark it as required it means we need to validate it as well.

seddonym’s picture

Version: 8.x-dev » 7.x-dev

Responding to #4, one use case is if we want to display the boolean as radio buttons, without an initial value (so users have to choose).

Anyway all this can be achieved using the List (text) field but sometimes it seemed a boolean field was more appropriate.

I'm also moving this back to version 7 (for which it is still an issue), but I've created a ticket for version 8 too.

tim.plunkett’s picture

Version: 7.x-dev » 8.x-dev

Keep it in the same issue.

droplet’s picture

Status: Active » Closed (cannot reproduce)

can't reproduce with latest -dev. seems it's fixed.

dww’s picture

Version: 8.x-dev » 7.x-dev
Status: Closed (cannot reproduce) » Active

Still a bug in 7.x, moving back.

droplet’s picture

junkbox’s picture

responding to #5 and #7...yeah at first it threw me into a logic loop...but you're right. 'Not Required' means false is submitted and therefore the field while 'not required' is inherently binary and works itself out, because it always gives a value. Forcing a tick also has it's use cases, 'tick here if you're over 18 and agree to the terms', so it's really win win. I think it's great to have the option for requirement and the logic is sound. Maybe a tool tip to stop dummies like me from thinking it's broke (assuming it's not) and freaking out about validation errors...then googling...then running across this post, might be a good thing.