Migx Filter Dropdown Not Populating

Summary

I am trying to populate a dropdown “filter” with a custom table but it does not seem to populate, details appear correct as i can populate the table via a CMP using the same packagename and classname with no issues. Is there something i am missing?

Step to reproduce

I have a custom table that works, as i can add. edit, remove from custom migx cmp as per screenshot below. Table does not have a different prefix, so it follows the structure of modx_ip_contenttypes

<model package="industrypro" baseClass="xPDOObject" platform="mysql" defaultEngine="InnoDB" phpdoc-package="industrypro" phpdoc-subpackage="model" version="1.1">
<object class="content_types" table="ip_contenttypes" extends="xPDOSimpleObject">
    <field key="name" dbtype="varchar" precision="20" phptype="string" null="false" default=""/>
    <field key="extension" dbtype="varchar" precision="20" phptype="string" null="false" default=""/>
    <field key="deleted" dbtype="int" precision="10" phptype="integer" null="false" default=""/>
    <field key="editedon" dbtype="datetime" phptype="datetime" null="false"/>
  </object>
</model>

I have created a filter with type of combobox and using the getcombo processor and have filled in the classname and the packagename correctly as per screenshots below.


Observed behavior

When i then load the CMP in the manager interface it does not populate the dropdown with anything, also no errors in the error log.
image

Expected behavior

Populate dropdown with the name of different types using the name field as specified in the getcombo-textfield

Environment

MODX 2.8.3
PHP 7.4
MySQL 5.7

Is there an error message in the MODX error log?
Something like “SELECT list is not in GROUP BY clause and contains nonaggregated column …”?


One possibility why it fails, is that in MySQL the sql-mode ONLY_FULL_GROUP_BY is set. If you can’t change the configuration of your MySQL-server, then you’ll have to create a custom getcombo-processor:

  • Copy the file core/components/migx/processors/mgr/default/getcombo.php into the folder core/components/industrypro/processors/mgr/default.
  • Then change this line in the copied file

to this:

$c->select($idfield . ' as combo_id, ' . $textfield . ' as combo_name');

That worked like a charm, i did indeed have that error you mentioned, i can probably change that setting in MySQL right now in development but probably not if it exists in production on the clients server so probably best i have a fall back.

I have one issue that still remains. So now when i change the field, it is passing the name instead of the ID when i try to filter the content of my separate table.

image
image

I want it to pass the ID of the element under “contenttype” instead of the name it is currently doing.

I have set up this in the getlist-where, would this be correct.
image
the grid it is filtering has the column called “type” which will have the id of the content type in it.

Sorry to double post,

I have resolved the issue by setting the SQL mode to Traditional in the core config. Below is some additional config i found on the Modx git that someone else had previously. Seems like a better approach so that even if i don’t have access to the SQL database directly i can edit it at the Modx level.

in core/config.php i added the following to the end of the file

$driver_options = array (
  PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
  PDO::MYSQL_ATTR_INIT_COMMAND => "SET sql_mode = 'TRADITIONAL'"
);

here is my final Migx config, i set the “type” to [[+contenttype]] as per the name of my filter and explicitly set the id field in the optional field

P.S i have also reverted back to the original getcombo.php file without your changes as i was able to resolve it via the driver change in the config in case anyone else comes across the issue

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.