Only one record allowed to have a check box checked

6 posts by 3 authors in: Forums > CMS Builder
Last Post: September 12, 2014   (RSS)

Hi All,

I'd like to be able to set the input validation for a "Committee Chairperson" check box in a multi-record table to, "user may not enter the same value as another record (not case-sensitive)" so that only one record can have that box checked at a time.

Any thoughts?

Thanks,

Jerry Kornbluth
 

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hey Jerry, this can be done in the database itself, but I don't know if you can do it through CMSBuilder.

I'll refer this to Dave, he might have a solution.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

I should specify - I think this can't be done with a checkbox field at all, so you may want to look into using another field type.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Dave - September 12, 2014

Hi Guys, 

When you set this option in the Field Editor: 

Unique       [X] user may not enter the same value as another record (not case-sensitive)

It checks that no other records have the same value, but it ignores "blank" 0-character values when checking.  So it doesn't work for checkboxes because checkboxes store their state as either 0 or 1 in the database meaning it would allow one record with a checked box and one with an unchecked box.

But what you could do instead of a checkbox would be to use a list field and set the list values as follows:

|No
1|Yes

And then check the "Unique" checkbox.  That would store blank "" for the No value and 1 for the Yes value (and you could use whatever you wanted instead of Yes/No).  Furthermore, it would only allow you to have one record with 1/Yes set and unlimited records with blank/No set.  

It's not a checkbox, but pretty close, and you can rely on consistent user input since they can only select those two options.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - September 12, 2014 - edited: September 12, 2014

WOW!!!!

What a great idea.

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php