Get Options from MySQL Advanced - Undefined index: listType Error
6 posts by 2 authors in: Forums > CMS Builder
Last Post: October 19, 2021 (RSS)
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.
Programmer
interactivetools.com
Hi Michael,
Thanks for that, fixed the error from showing in the admin but still getting the following errors in the log (see attached also)
E_NOTICE: Undefined index: listType
/cms/lib/menus/default/edit_functions.php (line 767)
/cms/admin.php?menu=blog&action=edit&num=79
E_NOTICE: Undefined index: listType
/cms/lib/menus/default/edit_functions.php (line 762)
/cms/admin.php?menu=blog&action=edit&num=79
BTW, forgot to mention this is v3.54 (Build 2280)
<?
// list fields w/ advanced filters - add onchange event handler to local filter field
if (@$fieldSchema['filterField']) {
$targetListField = $fieldSchema['name'];
$filterSchema = $GLOBALS['schema'][$fieldSchema['filterField']];
// $sourceField = ($filterSchema['listType'] == 'checkboxes' || $filterSchema['listType'] == 'pulldownMulti')? $filterSchema['name']."[]" : $filterSchema['name'] ;
$sourceField = (!empty($filterSchema['listType']) && ($filterSchema['listType'] == 'checkboxes' || $filterSchema['listType'] == 'pulldownMulti'))? $filterSchema['name']."[]" : $filterSchema['name'] ;
?>
<script type="text/javascript"><!--
$("[name='<?php echo $sourceField; ?>']").change(function () {
<?php if($filterSchema['listType'] == 'pulldownMulti'): ?>
newFilterValue = "\t";
$.each($("[name='<?php echo $sourceField ?>']").select2('data'), function( key, selectedOption ) {
newFilterValue = newFilterValue + selectedOption.id + "\t" ;
});
<?php elseif($filterSchema['listType'] == 'checkboxes') : ?>
newFilterValue = "\t";
$("[name='<?php echo $sourceField ?>']:checked").map(function(){
newFilterValue = newFilterValue + $(this).val()+ "\t" ;
});
<?php else: ?>
var newFilterValue = this.value;
<?php endif; ?>
var targetListField = '<?php echo $targetListField ?>';
updateListFieldOptions(targetListField, newFilterValue);
});
// --></script>
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') : ?>
Programmer
interactivetools.com
By Michael - October 19, 2021
Glad to hear that. Thanks.
Programmer
interactivetools.com