Get Options from MySQL Advanced - Undefined index: listType Error

6 posts by 2 authors in: Forums > CMS Builder
Last Post: October 19, 2021   (RSS)

By theclicklab - October 18, 2021

Hi there,

Getting Undefined index: listType errors on a list field that's using the mySQL advanced option to join two fields together:

SELECT num, CONCAT(name, ' - ',size)
FROM `<?php echo $TABLE_PREFIX ?>products`

The list gets output fine in the cms, but has errors at the end:

E_NOTICE: Undefined index: listType
/cms/lib/menus/default/edit_functions.php (line 766)
/cms/admin.php?menu=blog&action=edit&num=79

E_NOTICE: Undefined index: listType
/cms/lib/menus/default/edit_functions.php (line 761)
/cms/admin.php?menu=blog&action=edit&num=79

E_NOTICE: Undefined index: listType
/cms/lib/menus/default/edit_functions.php (line 757)
/cms/admin.php?menu=blog&action=edit&num=79

Size can sometimes be blank in case that helps.

Any tips to fix this? Thanks :)

By Michael - October 19, 2021

Hi @theclicklab,

I've successfully reproduced the issue you've described.  This will be fixed in the next CMSB release.  In the mean time if you'd like to resolve the issue in your current installation, look for the following line (around 766) in the /lib/menus/default/edit_function.php file:

$sourceField = ($filterSchema['listType'] == 'checkboxes' || $filterSchema['listType'] == 'pulldownMulti')? $filterSchema['name']."[]" : $filterSchema['name'] ;

and change it to read:

$sourceField = (!empty($filterSchema['listType']) && ($filterSchema['listType'] == 'checkboxes' || $filterSchema['listType'] == 'pulldownMulti'))? $filterSchema['name']."[]" : $filterSchema['name'] ;

That should take care of the PHP notice you're seeing.

Michael Sams
Programmer
interactivetools.com

By Michael - October 19, 2021

It looks like 2 additional lines need to be updated.

Try changing the following line (around 762) from:

<?php if($filterSchema['listType'] == 'pulldownMulti'): ?>

to this:

<?php if(!empty($filterSchema['listType']) && $filterSchema['listType'] == 'pulldownMulti'): ?>

And this line (around 767) from:

<?php elseif($filterSchema['listType'] == 'checkboxes') : ?>

to this:

<?php elseif(!empty($filterSchema['listType']) && $filterSchema['listType'] == 'checkboxes') : ?>
Michael Sams
Programmer
interactivetools.com

By theclicklab - October 19, 2021

Awesome thanks! That did the trick :)

By Michael - October 19, 2021

Glad to hear that.  Thanks.

Michael Sams
Programmer
interactivetools.com