Pre-Checking all entries marked as default in a multi value check box list

8 posts by 3 authors in: Forums > CMS Builder
Last Post: December 11, 2015   (RSS)

By gkornbluth - December 8, 2015

Hi All

My client’s exhibition submission information listings all include lists of guidelines, rules, and required entry materials to be sorted and shown in the viewer for that exhibition.

The lists are created from 3 multi value check box list fields that gets their values from the MySQL query.

(The exhibition_rules_list section currently has 2 fields, a list field called “Group” and a text field called “Rule”):

SELECT num, rule
  FROM `<?php echo $TABLE_PREFIX ?>exhibition_rules_list`
WHERE `group` LIKE '%guide%'

SELECT num, rule
  FROM `<?php echo $TABLE_PREFIX ?>exhibition_rules_list`
WHERE `group` LIKE '%mater%'

and

SELECT num, rule
  FROM `<?php echo $TABLE_PREFIX ?>exhibition_rules_list`
WHERE `group` LIKE '%rule%'


CLIENT'S NEEDS
The rules lists are getting kind of long and my client would like to be able to define a number of the  entries as “default” entries, and then possibly delete some and add others as required when creating a new submission information record.

They'd also like to easily change the status of the default entries from default to not default and back again, without affecting any existing submission information records.

FIRST APPROACH
I thought of creating a check box field in the “Exhibition Rules List” editor called “default”, and then using an if statement in the viewer that would show any rules where “default” == 1 or where the rule was selected in the list.

The problem is that this approach A) would  change all submission listings records, and B) there’s no feedback when creating a new submission information record, since all boxes will be unchecked whether the rule is a default rule or not..

QUESTION
Any idea how I can pre-check any “default” rules and yet have the ability to uncheck some and add others when creating new, or modifying existing listing records?

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

By Daryl - December 9, 2015

Hi Jerry,

Your first approach sounds good.

> A) would  change all submission listings records

I don't think adding "default" checkbox will change the existing submission listing records selected rules unless the selected rules record nums were changed.
So in the viewer page, when editing a submission listing record, if a default rule was not selected, then it should appear unchecked. 
While in the viewer page for adding new submission record, all the default rules will appear "checked".

> B) there’s no feedback when creating a new submission information record, since all boxes will be unchecked whether the rule is a default rule or not..  

Can you please elaborate this problem?

Thanks,

Daryl Maximo
PHP Programmer - interactivetools.com

By gkornbluth - December 9, 2015

Hi Daryl,

Thanks for looking at this.

Regarding the first part, sorry, I meant that since I was thinking of using an if statement in the viewer that looked to see if  the exhibition submission information listings record's list field item was checked, OR if the default box on the Exhibition Rules List record was checked  it would change the viewers for all existing records, not the actual record itself.

As to the second issue, if  the Exhibition Rules List record's  “default” box is checked, it  would not be reflected in the exhibition submission information listings record list field as a checked "Rule" on the back end, so when an exhibition submission information listings record was being created, the client would not be able to see if the rule was going to appear or not.

Hope that makes more sense.

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

By ross - December 10, 2015

Hi Jerry

Unfortunately, there isn't a way to dynamically set defaults for a multi checkbox field based on settings in the lookup table.

What you can do, though, is manually set the "Default Value" of the field as a tab (not just a bunch of spaces) separated list.

To do that, you need to look up the record numbers of the values you want to be set as default. Let's say you want 1, 7 and 16.

To enter a tab from the keyboard, you hold down ALT, hit the 0 key, then the 9 key and then let go of ALT. When you let go, the tab space will enter.

Using the numbers in my example above, your Default Value would be:

1716

Remember that this won't work if you just enter spaces. It needs to be tabs.

Let me know if you think this will work.

Thanks!

Default Value

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By gkornbluth - December 10, 2015 - edited: December 10, 2015

Hi Ross,

Thanks for thinking about this.

Sounds like the start of a good plan.

Bit confused though...

Where exactly would I enter these values?

How would they appear (would there be any verbal feedback in the new record regarding the rules chosen to be defaults)?

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

By ross - December 10, 2015

Sure thing Jerry. First off, here are my assumptions:

1. You have a section called: "Submission Information Listings".

2. In the "Submission Information Listings" section, you have the 3 multi-select checkbox fields that each pull in a different list of options from the "exhibition_rules_list" section.

---

The first step is to go to your "exhibition_rules_list" section and make note of the records numbers for the options you want to set as default in the first multi-select check box of "Submission Information Listings".  Let's say you pick 1, 7 and 16.

The second step is to go to the Section Editor for your "Submission Information Listings" and modify the multi-select field you just grabbed the record numbers for in the first step.

The third step is to enter the following into the "Default Values" field:

1716

Then hit save.  Note that the spaces between 1,7 and 16 above are tabs. I created the tabs by holding ALT then clicking (and letting go) 0, then clicking 9 (and letting go) and finally letting go of ALT.

Save this field and try creating a new record in "Submission Information Listings".

Also note that this will not work for existing records; only new records.

Does that make more sense? Give it a shot and let me know how you make out.

Thanks!

Submission Information Listings

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By gkornbluth - December 11, 2015 - edited: December 11, 2015

Thanks Ross, that worked like a charm...

I’m using windows 10 and it took me a while to figure out how to actually enter the tab character separators (for some reason, your suggestion didn't work for me using either the number pad or the numbers across the top of my keyboard).

The only method that worked for me was to open my notepad text editor, enter a tab character in a blank text document by pressing the tab key on my keyboard, then highlighting and copying the tab character to my clipboard. I could then paste that character after each record number.

I couldn't have done this without your help.

Thanks again,

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